summaryrefslogtreecommitdiffhomepage
path: root/coreutils
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/date.c7
-rw-r--r--coreutils/touch.c6
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)
/* If date string is given, update tm_time, and maybe set date */
if (date_str != NULL) {
+ int check_dst = 1;
/* Zero out fields - take her back to midnight! */
tm_time.tm_sec = 0;
tm_time.tm_min = 0;
@@ -276,12 +277,12 @@ int date_main(int argc UNUSED_PARAM, char **argv)
if (strptime(date_str, fmt_str2dt, &tm_time) == NULL)
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
} else {
- parse_datestr(date_str, &tm_time);
+ check_dst = parse_datestr(date_str, &tm_time);
}
/* Correct any day of week and day of year etc. fields */
- /* Be sure to recheck dst (but not if date is time_t format) */
- if (date_str[0] != '@')
+ /* Be sure to recheck dst (but not if date is UTC) */
+ if (check_dst)
tm_time.tm_isdst = -1;
ts.tv_sec = validate_tm_time(date_str, &tm_time);
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)
if (opts & (OPT_d|OPT_t)) {
struct tm tm_time;
time_t t;
+ int check_dst;
//memset(&tm_time, 0, sizeof(tm_time));
/* Better than memset: makes "HH:MM" dates meaningful */
time(&t);
localtime_r(&t, &tm_time);
- parse_datestr(date_str, &tm_time);
+ check_dst = parse_datestr(date_str, &tm_time);
/* Correct any day of week and day of year etc. fields */
- tm_time.tm_isdst = -1; /* Be sure to recheck dst */
+ if (check_dst)
+ tm_time.tm_isdst = -1; /* recheck dst unless date is UTC */
t = validate_tm_time(date_str, &tm_time);
timebuf[1].tv_sec = timebuf[0].tv_sec = t;