[git commit master 1/1] date: preserve isdst value if date is in time_t (unix time) format

Denys Vlasenko vda.linux at googlemail.com
Fri Dec 31 04:21:51 UTC 2010


commit: http://git.busybox.net/busybox/commit/?id=a5d3d3436b16bf6e1a92ed969e171ac812e8f906
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master

Signed-off-by: Alexey Soloviev <EXT-Alexey.Soloviev at nokia.com>
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 coreutils/date.c            |    4 +++-
 testsuite/date/date- at -works |   13 +++++++++++++
 2 files changed, 16 insertions(+), 1 deletions(-)
 create mode 100644 testsuite/date/date- at -works

diff --git a/coreutils/date.c b/coreutils/date.c
index c73fb5b..6ad5f1b 100644
--- a/coreutils/date.c
+++ b/coreutils/date.c
@@ -282,7 +282,9 @@ int date_main(int argc UNUSED_PARAM, char **argv)
 		}
 
 		/* Correct any day of week and day of year etc. fields */
-		tm_time.tm_isdst = -1;  /* Be sure to recheck dst */
+		/* Be sure to recheck dst (but not if date is time_t format) */
+		if (date_str[0] != '@')
+			tm_time.tm_isdst = -1;
 		ts.tv_sec = validate_tm_time(date_str, &tm_time);
 
 		maybe_set_utc(opt);
diff --git a/testsuite/date/date- at -works b/testsuite/date/date- at -works
new file mode 100644
index 0000000..03b4c7f
--- /dev/null
+++ b/testsuite/date/date- at -works
@@ -0,0 +1,13 @@
+# Tests for time_t value (unix time format)
+
+# Just before DST switched off
+test x"Sun Oct 31 03:59:59 EEST 2010" = x"`TZ=EET-2EEST,M3.5.0/3,M10.5.0/4 busybox date -d @1288486799`"
+
+# Just after DST switched off
+test x"Sun Oct 31 03:00:01 EET 2010" = x"`TZ=EET-2EEST,M3.5.0/3,M10.5.0/4 busybox date -d @1288486801`"
+
+# Just before DST switched on
+test x"Sun Mar 28 02:59:59 EET 2010" = x"`TZ=EET-2EEST,M3.5.0/3,M10.5.0/4 busybox date -d @1269737999`"
+
+# Just after DST switched on
+test x"Sun Mar 28 04:00:01 EEST 2010" = x"`TZ=EET-2EEST,M3.5.0/3,M10.5.0/4 busybox date -d @1269738001`"
-- 
1.7.2.2



More information about the busybox-cvs mailing list