]> gitweb.factorcode.org Git - factor.git/commitdiff
Yet-another HTTP cookie date format... how many variations are there?
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Thu, 25 Sep 2008 07:46:21 +0000 (02:46 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Thu, 25 Sep 2008 07:46:21 +0000 (02:46 -0500)
basis/calendar/format/format-tests.factor
basis/calendar/format/format.factor

index c433a118c2fe1be19e47c4d13ba01a9b5a5a6a9a..81930cdf49fa1963a702d74abe5d531b68316ba4 100755 (executable)
@@ -62,3 +62,15 @@ IN: calendar.format.tests
         T{ duration f 0 0 0 -5 0 0 }\r
     }\r
 ] [ "2008-05-26T00:37:42.12345-05:00" rfc3339>timestamp ] unit-test\r
+\r
+[\r
+    T{ timestamp\r
+        { year 2008 }\r
+        { month 10 }\r
+        { day 2 }\r
+        { hour 23 }\r
+        { minute 59 }\r
+        { second 59 }\r
+        { gmt-offset T{ duration f 0 0 0 0 0 0 } }\r
+    }\r
+] [ "Thursday, 02-Oct-2008 23:59:59 GMT" cookie-string>timestamp ] unit-test\r
index bfe438fae11b05392fe63b93d8e5130f336c6bd2..b15da4240998ddd4ffeca4b9dbba53a347ec4a7c 100755 (executable)
@@ -201,9 +201,13 @@ ERROR: invalid-timestamp-format ;
 : rfc822>timestamp ( str -- timestamp )\r
     [ (rfc822>timestamp) ] with-string-reader ;\r
 \r
+: check-day-name ( str -- )\r
+    [ day-abbreviations3 member? ] [ day-names member? ] bi or\r
+    check-timestamp drop ;\r
+\r
 : (cookie-string>timestamp-1) ( -- timestamp )\r
     timestamp new\r
-        "," read-token day-abbreviations3 member? check-timestamp drop\r
+        "," read-token check-day-name\r
         read1 CHAR: \s assert=\r
         "-" read-token checked-number >>day\r
         "-" read-token month-abbreviations index 1+ check-timestamp >>month\r
@@ -218,7 +222,7 @@ ERROR: invalid-timestamp-format ;
 \r
 : (cookie-string>timestamp-2) ( -- timestamp )\r
     timestamp new\r
-        read-sp day-abbreviations3 member? check-timestamp drop\r
+        read-sp check-day-name\r
         read-sp month-abbreviations index 1+ check-timestamp >>month\r
         read-sp checked-number >>day\r
         ":" read-token checked-number >>hour\r