ref: bdc2815d2b4b4481d884df0a581e44d34af443d6
parent: 0ea0bb526b6da68de61d2adca11e2dcea0be7670
author: Ori Bernstein <ori@eigenstate.org>
date: Thu Jun 25 12:55:34 EDT 2020
use fixed timezone in parsing code.
--- a/cmd/date.rc
+++ b/cmd/date.rc
@@ -1,5 +1,8 @@
#!/bin/rc
+rfork en
+cat /adm/timezone/GMT > /env/timezone
+
nl='
'
@@ -6,6 +9,9 @@
fn check {
r=`$nl{seconds $1}
if(! ~ $r $2){
+ echo "$"r"
+ echo "$"2"
+ echo $status
>[1=2] echo fail: $1: got $r expected $2
exit 'fail'
}
@@ -12,6 +18,7 @@
}
# examples from manpage, and shuffles
+rfork ne
check '23 may 2011' 1306108800
check 'may 23 2011' 1306108800
check 'may 2011 23' 1306108800
@@ -23,7 +30,7 @@
check '23 may 2011 edt' 1306123200
check '23 may 2011 gmt' 1306108800
-# now with times
+# now with all variations on times.
check 'may 23 2011 0' 1306108800
check 'may 23 2011 0:1' 1306108860
check 'may 23 2011 0:1:2' 1306108862
@@ -41,5 +48,13 @@
# colloquial american format (eww)
check '06/14/2020' 1592092800
check '06/01/2020' 1590969600
+
+
+# Arizona has no DST
+@{
+ rfork en
+ cat /adm/timezone/US_Arizona >/env/timezone
+ check 'Mon, Jun 21 17:38:02 MST 2020' 1592782682
+}
exit ''