diff options
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/date.c | 7 | ||||
-rw-r--r-- | coreutils/touch.c | 6 |
2 files changed, 8 insertions, 5 deletions
diff --git a/coreutils/date.c b/coreutils/date.c index 7061f1719..abcc37c33 100644 --- a/coreutils/date.c +++ b/coreutils/date.c | |||
@@ -266,6 +266,7 @@ int date_main(int argc UNUSED_PARAM, char **argv) | |||
266 | 266 | ||
267 | /* If date string is given, update tm_time, and maybe set date */ | 267 | /* If date string is given, update tm_time, and maybe set date */ |
268 | if (date_str != NULL) { | 268 | if (date_str != NULL) { |
269 | int check_dst = 1; | ||
269 | /* Zero out fields - take her back to midnight! */ | 270 | /* Zero out fields - take her back to midnight! */ |
270 | tm_time.tm_sec = 0; | 271 | tm_time.tm_sec = 0; |
271 | tm_time.tm_min = 0; | 272 | tm_time.tm_min = 0; |
@@ -276,12 +277,12 @@ int date_main(int argc UNUSED_PARAM, char **argv) | |||
276 | if (strptime(date_str, fmt_str2dt, &tm_time) == NULL) | 277 | if (strptime(date_str, fmt_str2dt, &tm_time) == NULL) |
277 | bb_error_msg_and_die(bb_msg_invalid_date, date_str); | 278 | bb_error_msg_and_die(bb_msg_invalid_date, date_str); |
278 | } else { | 279 | } else { |
279 | parse_datestr(date_str, &tm_time); | 280 | check_dst = parse_datestr(date_str, &tm_time); |
280 | } | 281 | } |
281 | 282 | ||
282 | /* Correct any day of week and day of year etc. fields */ | 283 | /* Correct any day of week and day of year etc. fields */ |
283 | /* Be sure to recheck dst (but not if date is time_t format) */ | 284 | /* Be sure to recheck dst (but not if date is UTC) */ |
284 | if (date_str[0] != '@') | 285 | if (check_dst) |
285 | tm_time.tm_isdst = -1; | 286 | tm_time.tm_isdst = -1; |
286 | ts.tv_sec = validate_tm_time(date_str, &tm_time); | 287 | ts.tv_sec = validate_tm_time(date_str, &tm_time); |
287 | ts.tv_nsec = 0; | 288 | ts.tv_nsec = 0; |
diff --git a/coreutils/touch.c b/coreutils/touch.c index 78100ba1d..7e13a27be 100644 --- a/coreutils/touch.c +++ b/coreutils/touch.c | |||
@@ -140,15 +140,17 @@ int touch_main(int argc UNUSED_PARAM, char **argv) | |||
140 | if (opts & (OPT_d|OPT_t)) { | 140 | if (opts & (OPT_d|OPT_t)) { |
141 | struct tm tm_time; | 141 | struct tm tm_time; |
142 | time_t t; | 142 | time_t t; |
143 | int check_dst; | ||
143 | 144 | ||
144 | //memset(&tm_time, 0, sizeof(tm_time)); | 145 | //memset(&tm_time, 0, sizeof(tm_time)); |
145 | /* Better than memset: makes "HH:MM" dates meaningful */ | 146 | /* Better than memset: makes "HH:MM" dates meaningful */ |
146 | time(&t); | 147 | time(&t); |
147 | localtime_r(&t, &tm_time); | 148 | localtime_r(&t, &tm_time); |
148 | parse_datestr(date_str, &tm_time); | 149 | check_dst = parse_datestr(date_str, &tm_time); |
149 | 150 | ||
150 | /* Correct any day of week and day of year etc. fields */ | 151 | /* Correct any day of week and day of year etc. fields */ |
151 | tm_time.tm_isdst = -1; /* Be sure to recheck dst */ | 152 | if (check_dst) |
153 | tm_time.tm_isdst = -1; /* recheck dst unless date is UTC */ | ||
152 | t = validate_tm_time(date_str, &tm_time); | 154 | t = validate_tm_time(date_str, &tm_time); |
153 | 155 | ||
154 | timebuf[1].tv_sec = timebuf[0].tv_sec = t; | 156 | timebuf[1].tv_sec = timebuf[0].tv_sec = t; |