calendar.format: Fix timestamp parsing when there is no timezone. Fixes #861.

db4
Doug Coleman 2013-04-24 08:20:48 -07:00
parent f1b21b1827
commit 9f28391e6b
2 changed files with 22 additions and 7 deletions

View File

@ -83,3 +83,14 @@ IN: calendar.format.tests
[ ]
[ { 2008 2009 } [ year. ] each ] unit-test
[
T{ timestamp
{ year 2013 }
{ month 4 }
{ day 23 }
{ hour 13 }
{ minute 50 }
{ second 24 }
}
] [ "2013-04-23T13:50:24" rfc3339>timestamp ] unit-test

View File

@ -146,13 +146,17 @@ M: timestamp year. ( timestamp -- )
{ { CHAR: + [ 1 ] } { CHAR: - [ -1 ] } } case time* ;
: read-rfc3339-gmt-offset ( ch -- dt )
dup CHAR: Z = [ drop instant ] [
[
read-00 hours
read1 { { CHAR: : [ read-00 ] } { f [ 0 ] } } case minutes
time+
] dip signed-gmt-offset
] if ;
{
{ f [ instant ] }
{ CHAR: Z [ instant ] }
[
[
read-00 hours
read1 { { CHAR: : [ read-00 ] } { f [ 0 ] } } case minutes
time+
] dip signed-gmt-offset
]
} case ;
: read-ymd ( -- y m d )
read-0000 "-" expect read-00 "-" expect read-00 ;