2
* BURG - Brand-new Universal loadeR from GRUB
3
* Copyright 2010 Bean Lee - All Rights Reserved
5
* BURG is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* (at your option) any later version.
10
* BURG is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with BURG. If not, see <http://www.gnu.org/licenses/>.
21
#include <grub/misc.h>
22
#include <grub/datetime.h>
23
#include <grub/command.h>
24
#include <grub/i18n.h>
27
grub_cmd_time (grub_command_t cmd __attribute__ ((unused)),
28
int argc, char **args)
30
struct grub_datetime t1, t2;
35
grub_error (GRUB_ERR_BAD_ARGUMENT, "no command");
37
if (grub_get_datetime (&t1))
40
err = grub_command_execute (args[0], argc - 1, args + 1);
42
if (grub_get_datetime (&t2))
45
delta = (int) t2.year - (int) t1.year;
46
delta = delta * 365 + (int) t2.day - (int) t1.day;
47
delta = delta * 24 + (int) t2.hour - (int) t1.hour;
48
delta = delta * 60 + (int) t2.minute - (int) t1.minute;
49
delta = delta * 60 + (int) t2.second - (int) t1.second;
51
grub_printf ("%d seconds\n", delta);
56
static grub_command_t cmd;
61
grub_register_command ("time", grub_cmd_time,
63
N_("Execute COMMAND and print run time."));
68
grub_unregister_command (cmd);