calendar.format: change rfc3339 to always print microseconds.
parent
7328fa306f
commit
794baf3222
|
@ -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
|
||||
|
|
|
@ -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 ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue