diff options
author | Ron Yorston <rmy@pobox.com> | 2021-09-16 10:26:14 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-09-17 00:11:30 +0200 |
commit | 9fe1548bbfde548d54acaab113656a56ea0ccc72 (patch) | |
tree | babe79b4f502417ca91a8fab3099f29ff718de19 /testsuite/date/date-timezone | |
parent | 83e20cb81ca6d22a1ca268a0a64523b5af67325a (diff) | |
download | busybox-w32-9fe1548bbfde548d54acaab113656a56ea0ccc72.tar.gz busybox-w32-9fe1548bbfde548d54acaab113656a56ea0ccc72.tar.bz2 busybox-w32-9fe1548bbfde548d54acaab113656a56ea0ccc72.zip |
date,touch: allow timezone offsets in dates
Allow ISO 8601 style dates to include a timezone offset. Like
the '@' format these dates aren't relative to the user's current
timezone and shouldn't be subject to DST adjustment.
- The implementation uses the strptime() '%z' format specifier.
This an extension which may not be available so the use of
timezones is a configuration option.
- The 'touch' applet has been updated to respect whether DST
adjustment is required, matching 'date'.
function old new delta
parse_datestr 624 730 +106
static.fmt_str 106 136 +30
touch_main 388 392 +4
date_main 818 819 +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 141/0) Total: 141 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to '')
-rw-r--r-- | testsuite/date/date-timezone | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/testsuite/date/date-timezone b/testsuite/date/date-timezone new file mode 100644 index 000000000..8628aa1d7 --- /dev/null +++ b/testsuite/date/date-timezone | |||
@@ -0,0 +1,32 @@ | |||
1 | # FEATURE: CONFIG_FEATURE_TIMEZONE | ||
2 | |||
3 | # 'Z' is UTC | ||
4 | dt=$(TZ=UTC0 busybox date -d '1999-1-2 3:4:5Z') | ||
5 | dt=$(echo "$dt" | cut -b1-19) | ||
6 | test x"$dt" = x"Sat Jan 2 03:04:05" | ||
7 | |||
8 | # '+0600' is six hours ahead of UTC | ||
9 | dt=$(TZ=UTC0 busybox date -d '1999-1-2 3:4:5 +0600') | ||
10 | dt=$(echo "$dt" | cut -b1-19) | ||
11 | test x"$dt" = x"Fri Jan 1 21:04:05" | ||
12 | |||
13 | # '-0600' is six hours behind UTC | ||
14 | dt=$(TZ=UTC0 busybox date -d '1999-1-2 3:4:5 -0600') | ||
15 | dt=$(echo "$dt" | cut -b1-19) | ||
16 | test x"$dt" = x"Sat Jan 2 09:04:05" | ||
17 | |||
18 | # before dst is switched on | ||
19 | dt=$(TZ=GMT0BST,M3.5.0/1,M10.5.0/2 busybox date -d '2021-03-28 00:59:59 +0000') | ||
20 | test x"$dt" = x"Sun Mar 28 00:59:59 GMT 2021" | ||
21 | |||
22 | # after dst is switched on | ||
23 | dt=$(TZ=GMT0BST,M3.5.0/1,M10.5.0/2 busybox date -d '2021-03-28 01:00:01 +0000') | ||
24 | test x"$dt" = x"Sun Mar 28 02:00:01 BST 2021" | ||
25 | |||
26 | # before dst is switched off | ||
27 | dt=$(TZ=GMT0BST,M3.5.0/1,M10.5.0/2 busybox date -d '2021-10-31 00:00:01 +0000') | ||
28 | test x"$dt" = x"Sun Oct 31 01:00:01 BST 2021" | ||
29 | |||
30 | # after dst is switched off: back to 01:00:01 but with different TZ | ||
31 | dt=$(TZ=GMT0BST,M3.5.0/1,M10.5.0/2 busybox date -d '2021-10-31 01:00:01 +0000') | ||
32 | test x"$dt" = x"Sun Oct 31 01:00:01 GMT 2021" | ||