diff options
author | Steve Bennett <steveb@workware.net.au> | 2019-05-20 10:15:43 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2019-05-20 15:38:54 +1000 |
commit | bd33d63c274c5bd13f188d961ed83e85ef0d0442 (patch) | |
tree | c89bace6bd16dc98dc406f956e6438cde4ed7488 | |
parent | 3fc959b9ad6827e997ad92ed449afcbb7560ac5d (diff) | |
download | jimtcl-bd33d63c274c5bd13f188d961ed83e85ef0d0442.zip jimtcl-bd33d63c274c5bd13f188d961ed83e85ef0d0442.tar.gz jimtcl-bd33d63c274c5bd13f188d961ed83e85ef0d0442.tar.bz2 |
clock scan: Unspecified fields use the current date/time
When scanning a time with unspecified fields, those fields
should use the current date/time, not 1 Jan 1900.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rw-r--r-- | jim-clock.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/jim-clock.c b/jim-clock.c index e1c2d76..e489af8 100644 --- a/jim-clock.c +++ b/jim-clock.c @@ -122,7 +122,7 @@ static int clock_cmd_scan(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { char *pt; struct tm tm; - /*time_t now = time(NULL);*/ + time_t now = time(NULL); /* No default format */ struct clock_options options = { 0, NULL }; @@ -137,10 +137,7 @@ static int clock_cmd_scan(Jim_Interp *interp, int argc, Jim_Obj *const *argv) return -1; } - /* Set unspecified fields to 0, e.g. HH:MM becomes 00:00 */ - memset(&tm, 0, sizeof(tm)); - /* But this is 1-based */ - tm.tm_mday = 1; + localtime_r(&now, &tm); pt = strptime(Jim_String(argv[0]), options.format, &tm); if (pt == 0 || *pt != 0) { |