--- a/RegressionTests__TimeAndDateTest.st Wed Nov 05 17:48:40 2014 +0100
+++ b/RegressionTests__TimeAndDateTest.st Wed Nov 05 21:07:56 2014 +0100
@@ -190,6 +190,8 @@
{ #( 5 53 2009) "2009-W53-5" . (Date newDay:1 month:1 year:2010) } .
{ #( 6 53 2009) "2009-W53-6" . (Date newDay:2 month:1 year:2010) } .
{ #( 7 53 2009) "2009-W53-7" . (Date newDay:3 month:1 year:2010) } .
+
+ { #( 1 1 1997) "1997-W01-1" . (Date newDay:30 month:12 year:1996) } .
} do:[:eachPair |
|dwy d1 d2 dayInWeek weekNr year|
@@ -246,6 +248,80 @@
"
self new test_06_calenderWeek_fails
"
+!
+
+test_07_readingISO8601
+ {
+ { '1995-02-20T13:11:06.123' . '1995-02-20 13:11:06.123' } .
+ { '1995-02-20T13:11:06' . '1995-02-20 13:11:06.000' } .
+ { '1995-02T13:11:06' . '1995-02-01 13:11:06.000' } .
+ { '1995T13:11:06' . '1995-01-01 13:11:06.000' } .
+ { '1995T13:11' . '1995-01-01 13:11:00.000' } .
+ { '1995T13:11.5' . '1995-01-01 13:11:30.000' } .
+ { '1995T13:11,5' . '1995-01-01 13:11:30.000' } .
+ { '1995T13' . '1995-01-01 13:00:00.000' } .
+ { '1995T13.25' . '1995-01-01 13:15:00.000' } .
+ { '1995T13.333333' . '1995-01-01 13:19:59.999' } .
+ { '1995' . '1995-01-01 00:00:00.000' } .
+ { '1995-02' . '1995-02-01 00:00:00.000' } .
+ { '19950204' . '1995-02-04 00:00:00.000' } .
+
+ "/ day in year
+ { '1995-001' . '1995-01-01 00:00:00.000' } .
+ { '1995-035' . '1995-02-04 00:00:00.000' } .
+ { '1995035' . '1995-02-04 00:00:00.000' } .
+
+ { '1997-01-01' . '1997-01-01 00:00:00.000' } .
+ "/ week and weekday
+ { '1997-W01' . '1996-12-30 00:00:00.000' } .
+ { '1997W01' . '1996-12-30 00:00:00.000' } .
+ { '1997W01-1' . '1996-12-30 00:00:00.000' } .
+ { '1997W011' . '1996-12-30 00:00:00.000' } .
+ { '1997W01' . '1996-12-30 00:00:00.000' } .
+ { '1997W01-2' . '1996-12-31 00:00:00.000' } .
+ { '1997-W01-2' . '1996-12-31 00:00:00.000' } .
+ { '1997W012' . '1996-12-31 00:00:00.000' } .
+ { '2014W40' . '2014-09-29 00:00:00.000' } .
+ { '2014W44-4' . '2014-10-30 00:00:00.000' } .
+ { '2014W01' . '2013-12-30 00:00:00.000' } .
+ { '2014W01-1' . '2013-12-30 00:00:00.000' } .
+ { '2014W01-2' . '2013-12-31 00:00:00.000' } .
+ { '2014W01-3' . '2014-01-01 00:00:00.000' } .
+
+ { '1995-02-20 13:11' . '1995-02-20 13:11:00.000' } .
+ { '1995-02-20 1311' . '1995-02-20 13:11:00.000' } .
+ { '1995-02-20 13' . '1995-02-20 13:00:00.000' } .
+ { '1995-02-20 235959' . '1995-02-20 23:59:59.000' } .
+ { '19950220 235959' . '1995-02-20 23:59:59.000' } .
+ { '19950220 23:59:59.9942' . '1995-02-20 23:59:59.994' } .
+ { '19950220 235959.9942' . '1995-02-20 23:59:59.994' } .
+
+ "/ local vs. UTC
+ { '1995-02-20 13:11:06' . '1995-02-20 13:11:06.000' } .
+ { '1995-02-20 13:11:06Z' . '1995-02-20 13:11:06.000' } .
+ { '1995-02-20 13:11:06+01' . '1995-02-20 12:11:06.000' } .
+ { '1995-02-20 13:11:06+01:00' . '1995-02-20 12:11:06.000' } .
+ { '1995-02-20 13:11:06+01:30' . '1995-02-20 11:41:06.000' } .
+ { '1995-02-20 13:11:06+0130' . '1995-02-20 11:41:06.000' } .
+ { '1995-02-20 13:11:06-01' . '1995-02-20 14:11:06.000' } .
+ { '1995-02-20 13:11:06-01:00' . '1995-02-20 14:11:06.000' } .
+ { '1995-02-20 13:11:06-01:30' . '1995-02-20 14:41:06.000' } .
+ { '1995-02-20 13:11:06-0130' . '1995-02-20 14:41:06.000' } .
+
+ "/ 24 is allowed with ISO, and is 00:00 of the next day:
+ { '1995-02-20 24:00:00' . '1995-02-21 00:00:00.000' } .
+ } do:[:eachPair |
+ |s1 d s|
+
+ s1 := eachPair first.
+ d := UtcTimestamp readIso8601FormatFrom:s1.
+ s := eachPair second.
+ self assert:(d asString = s) description:'expected: ',s,' got:',d printString.
+ ].
+
+ "
+ self new test_07_readingISO8601
+ "
! !
!TimeAndDateTest class methodsFor:'documentation'!