]> gitweb.factorcode.org Git - factor.git/commitdiff
calendar.format: change rfc3339 to always print microseconds.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 8 Oct 2014 22:36:08 +0000 (15:36 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 8 Oct 2014 22:40:04 +0000 (15:40 -0700)
basis/calendar/format/format-tests.factor
basis/calendar/format/format.factor

index 8b9885a63c378ccecbfaf7da5a907cb3320dbfd1..b1598df2fe12eb780984d379647ef8408c7ebf5d 100644 (file)
@@ -95,7 +95,7 @@ IN: calendar.format.tests
     }
 ] [ "2013-04-23T13:50:24" rfc3339>timestamp ] unit-test
 
-{ "2001-12-14T21:59:43.1-05:00" } [ "2001-12-14T21:59:43.1-05:00" rfc3339>timestamp timestamp>rfc3339 ] unit-test
+{ "2001-12-14T21:59:43.100000-05:00" } [ "2001-12-14T21:59:43.1-05:00" rfc3339>timestamp timestamp>rfc3339 ] unit-test
 
 [
     T{ timestamp
index 774d8121a6eee36b668255e02b3f17d4cd385bcc..aa024606071a2ed9cddad6c5eea2bd77bb49d601 100644 (file)
@@ -136,16 +136,12 @@ M: timestamp year. ( timestamp -- )
 
 ! Should be enough for anyone, allows to not do a fancy
 ! algorithm to detect infinite decimals (e.g 1/3)
-: write-rfc3339-seconds ( timestamp -- )
-    second>> 1 mod [
-        >float "%.6f" format-float [ CHAR: 0 = ] trim
-        dup length 1 > [ write ] [ drop ] if
-    ] unless-zero ;
+: ss.SSSSSS ( timestamp -- )
+    second>> >float "%.6f" format-float 9 CHAR: 0 pad-head write ;
 
 : (timestamp>rfc3339) ( timestamp -- )
     {
-        YYYY "-" MM "-" DD "T" hh ":" mm ":" ss
-        write-rfc3339-seconds
+        YYYY "-" MM "-" DD "T" hh ":" mm ":" ss.SSSSSS
         [ gmt-offset>> write-rfc3339-gmt-offset ]
     } formatted ;