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
|
] [ "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
|
T{ timestamp
|
||||||
|
|
|
@ -136,16 +136,12 @@ M: timestamp year. ( timestamp -- )
|
||||||
|
|
||||||
! Should be enough for anyone, allows to not do a fancy
|
! Should be enough for anyone, allows to not do a fancy
|
||||||
! algorithm to detect infinite decimals (e.g 1/3)
|
! algorithm to detect infinite decimals (e.g 1/3)
|
||||||
: write-rfc3339-seconds ( timestamp -- )
|
: ss.SSSSSS ( timestamp -- )
|
||||||
second>> 1 mod [
|
second>> >float "%.6f" format-float 9 CHAR: 0 pad-head write ;
|
||||||
>float "%.6f" format-float [ CHAR: 0 = ] trim
|
|
||||||
dup length 1 > [ write ] [ drop ] if
|
|
||||||
] unless-zero ;
|
|
||||||
|
|
||||||
: (timestamp>rfc3339) ( timestamp -- )
|
: (timestamp>rfc3339) ( timestamp -- )
|
||||||
{
|
{
|
||||||
YYYY "-" MM "-" DD "T" hh ":" mm ":" ss
|
YYYY "-" MM "-" DD "T" hh ":" mm ":" ss.SSSSSS
|
||||||
write-rfc3339-seconds
|
|
||||||
[ gmt-offset>> write-rfc3339-gmt-offset ]
|
[ gmt-offset>> write-rfc3339-gmt-offset ]
|
||||||
} formatted ;
|
} formatted ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue