summaryrefslogtreecommitdiffstats
path: root/login-utils/last.c
diff options
context:
space:
mode:
authorSami Kerola2013-08-26 22:43:05 +0200
committerSami Kerola2013-08-29 19:14:08 +0200
commit3a4ae395a4065bfa9df29faa022f056e4217c3d8 (patch)
treed3ae55c79f2f5822eafe66916462400dbe5b81b0 /login-utils/last.c
parentlib/strutils: move *swith() functions to private library (diff)
downloadkernel-qcow2-util-linux-3a4ae395a4065bfa9df29faa022f056e4217c3d8.tar.gz
kernel-qcow2-util-linux-3a4ae395a4065bfa9df29faa022f056e4217c3d8.tar.xz
kernel-qcow2-util-linux-3a4ae395a4065bfa9df29faa022f056e4217c3d8.zip
last: parse easy to use time formats
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'login-utils/last.c')
-rw-r--r--login-utils/last.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/login-utils/last.c b/login-utils/last.c
index 336703874..df784361d 100644
--- a/login-utils/last.c
+++ b/login-utils/last.c
@@ -47,6 +47,7 @@
#include "closestream.h"
#include "carefulputc.h"
#include "strutils.h"
+#include "time-util.h"
#ifndef SHUTDOWN_TIME
# define SHUTDOWN_TIME 254
@@ -735,6 +736,7 @@ int main(int argc, char **argv)
time_t until = 0; /* at what time to stop parsing the file */
time_t present = 0; /* who where present at time_t */
+ usec_t p;
static const struct option long_opts[] = {
{ "limit", required_argument, NULL, 'n' },
@@ -795,13 +797,19 @@ int main(int argc, char **argv)
break;
case 'p':
present = parsetm(optarg);
- if (present == (time_t) -1)
+ if (present != (time_t) -1)
+ break;
+ if (parse_timestamp(optarg, &p) < 0)
errx(EXIT_FAILURE, _("invalid time value \"%s\""), optarg);
+ present = (time_t) (p / 1000000);
break;
case 't':
until = parsetm(optarg);
- if (until == (time_t) -1)
+ if (until != (time_t) -1)
+ break;
+ if (parse_timestamp(optarg, &p) < 0)
errx(EXIT_FAILURE, _("invalid time value \"%s\""), optarg);
+ until = (time_t) (p / 1000000);
break;
case 'w':
if (UT_NAMESIZE > name_len)