]> gitweb.factorcode.org Git - factor.git/commitdiff
calendar.format: Fix timestamp parsing when there is no timezone. Fixes #861.
authorDoug Coleman <doug.coleman@gmail.com>
Wed, 24 Apr 2013 15:20:48 +0000 (08:20 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Wed, 24 Apr 2013 15:23:17 +0000 (08:23 -0700)
basis/calendar/format/format-tests.factor
basis/calendar/format/format.factor

index cb1ff0b60f2e11d717c967fd0e7ee6a9d0ec76bb..4fee482df59bc8675081a2e0cdcb05e964bc132b 100644 (file)
@@ -83,3 +83,14 @@ IN: calendar.format.tests
 \r
 [ ]\r
 [ { 2008 2009 } [ year. ] each ] unit-test\r
+\r
+[\r
+    T{ timestamp\r
+        { year 2013 }\r
+        { month 4 }\r
+        { day 23 }\r
+        { hour 13 }\r
+        { minute 50 }\r
+        { second 24 }\r
+    }\r
+] [ "2013-04-23T13:50:24" rfc3339>timestamp ] unit-test\r
index e2af02a3ccb02986ca864a1a0b58de6009d86847..e6e30136e7468b5d352a48baef99a448596e0636 100644 (file)
@@ -146,13 +146,17 @@ M: timestamp year. ( timestamp -- )
     { { CHAR: + [ 1 ] } { CHAR: - [ -1 ] } } case time* ;\r
 \r
 : read-rfc3339-gmt-offset ( ch -- dt )\r
-    dup CHAR: Z = [ drop instant ] [\r
-        [\r
-            read-00 hours\r
-            read1 { { CHAR: : [ read-00 ] } { f [ 0 ] } } case minutes\r
-            time+\r
-        ] dip signed-gmt-offset\r
-    ] if ;\r
+    {\r
+        { f [ instant ] }\r
+        { CHAR: Z [ instant ] }\r
+        [ \r
+            [\r
+                read-00 hours\r
+                read1 { { CHAR: : [ read-00 ] } { f [ 0 ] } } case minutes\r
+                time+\r
+            ] dip signed-gmt-offset\r
+        ]\r
+    } case ;\r
 \r
 : read-ymd ( -- y m d )\r
     read-0000 "-" expect read-00 "-" expect read-00 ;\r