diff options
author | Rob Landley <rob@landley.net> | 2014-10-01 19:57:34 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2014-10-01 19:57:34 -0500 |
commit | 76678fa5730dfced54c95696e77fdbc6c9c9e839 (patch) | |
tree | ac3c415b9215ea05a0b8412fbfcc4cdc28441c1e /toys/posix | |
parent | 9588d289ef381ee7dd68ef35990362ebf70366e4 (diff) | |
download | toybox-76678fa5730dfced54c95696e77fdbc6c9c9e839.tar.gz |
Bugfix from Ashwini Sharma: Z timezone required by posix for touch but not for libc, so we have to implement it here.
Diffstat (limited to 'toys/posix')
-rw-r--r-- | toys/posix/touch.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/toys/posix/touch.c b/toys/posix/touch.c index 0e0677e5..71ddc434 100644 --- a/toys/posix/touch.c +++ b/toys/posix/touch.c @@ -36,7 +36,7 @@ int fetch(char *file, struct timeval *tv, unsigned flags) { struct stat st; - if (stat(TT.file, &st)) return 1; + if (stat(file, &st)) return 1; if (flags & FLAG_a) { tv[0].tv_sec = st.st_atime; @@ -73,6 +73,12 @@ void touch_main(void) date = TT.date; i = strlen(date); if (i) { + // Trailing Z means UTC timezone, don't expect libc to know this. + if (toupper(date[i-1])=='Z') { + date[i-1] = 0; + setenv("TZ", "UTC0", 1); + localtime_r(&(tv->tv_sec), &tm); + } s = strptime(date, "%Y-%m-%dT%T", &tm); if (s && *s=='.') { sscanf(s, ".%d%n", &i, &len); |