diff options
Diffstat (limited to 'coreutils/date.c')
-rw-r--r-- | coreutils/date.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/coreutils/date.c b/coreutils/date.c index f7e9a8d0e..b9b7fd2cb 100644 --- a/coreutils/date.c +++ b/coreutils/date.c | |||
@@ -276,6 +276,9 @@ int date_main(int argc UNUSED_PARAM, char **argv) | |||
276 | time(&ts.tv_sec); | 276 | time(&ts.tv_sec); |
277 | #endif | 277 | #endif |
278 | } | 278 | } |
279 | #if !ENABLE_FEATURE_DATE_NANO | ||
280 | ts.tv_nsec = 0; | ||
281 | #endif | ||
279 | localtime_r(&ts.tv_sec, &tm_time); | 282 | localtime_r(&ts.tv_sec, &tm_time); |
280 | 283 | ||
281 | /* If date string is given, update tm_time, and maybe set date */ | 284 | /* If date string is given, update tm_time, and maybe set date */ |
@@ -298,9 +301,10 @@ int date_main(int argc UNUSED_PARAM, char **argv) | |||
298 | if (date_str[0] != '@') | 301 | if (date_str[0] != '@') |
299 | tm_time.tm_isdst = -1; | 302 | tm_time.tm_isdst = -1; |
300 | ts.tv_sec = validate_tm_time(date_str, &tm_time); | 303 | ts.tv_sec = validate_tm_time(date_str, &tm_time); |
304 | ts.tv_nsec = 0; | ||
301 | 305 | ||
302 | /* if setting time, set it */ | 306 | /* if setting time, set it */ |
303 | if ((opt & OPT_SET) && stime(&ts.tv_sec) < 0) { | 307 | if ((opt & OPT_SET) && clock_settime(CLOCK_REALTIME, &ts) < 0) { |
304 | bb_simple_perror_msg("can't set date"); | 308 | bb_simple_perror_msg("can't set date"); |
305 | } | 309 | } |
306 | } | 310 | } |