Bug fixes for lcs.diff2html; xml.writer
[factor/jcg.git] / basis / calendar / format / format-tests.factor
blob81930cdf49fa1963a702d74abe5d531b68316ba4
1 USING: calendar.format calendar kernel math tools.test\r
2 io.streams.string accessors io math.order ;\r
3 IN: calendar.format.tests\r
4 \r
5 [ 0 ] [\r
6     "Z" [ read1 read-rfc3339-gmt-offset ] with-string-reader duration>hours\r
7 ] unit-test\r
8 \r
9 [ 1 ] [\r
10     "+01" [ read1 read-rfc3339-gmt-offset ] with-string-reader duration>hours\r
11 ] unit-test\r
13 [ -1 ] [\r
14     "-01" [ read1 read-rfc3339-gmt-offset ] with-string-reader duration>hours\r
15 ] unit-test\r
17 [ -1-1/2 ] [\r
18     "-01:30" [ read1 read-rfc3339-gmt-offset ] with-string-reader duration>hours\r
19 ] unit-test\r
21 [ 1+1/2 ] [\r
22     "+01:30" [ read1 read-rfc3339-gmt-offset ] with-string-reader duration>hours\r
23 ] unit-test\r
25 [ ] [ now timestamp>rfc3339 drop ] unit-test\r
26 [ ] [ now timestamp>rfc822 drop ] unit-test\r
28 [ 8/1000 -4 ] [\r
29     "2008-04-19T04:56:00.008-04:00" rfc3339>timestamp\r
30     [ second>> ] [ gmt-offset>> hour>> ] bi\r
31 ] unit-test\r
33 [ T{ duration f 0 0 0 0 0 0 } ] [\r
34     "GMT" parse-rfc822-gmt-offset\r
35 ] unit-test\r
37 [ T{ duration f 0 0 0 -5 0 0 } ] [\r
38     "-0500" parse-rfc822-gmt-offset\r
39 ] unit-test\r
41 [ T{ timestamp f 2008 4 22 14 36 12 T{ duration f 0 0 0 0 0 0 } } ] [\r
42     "Tue, 22 Apr 2008 14:36:12 GMT" rfc822>timestamp\r
43 ] unit-test\r
45 [ t ] [ now dup timestamp>rfc822 rfc822>timestamp time- 1 seconds before? ] unit-test\r
47 [ t ] [ now dup timestamp>cookie-string cookie-string>timestamp time- 1 seconds before? ] unit-test\r
49 [ "Sun, 4 May 2008 07:00:00" ] [\r
50     "Sun May 04 07:00:00 2008 GMT" cookie-string>timestamp\r
51     timestamp>string\r
52 ] unit-test\r
54 [\r
55     T{ timestamp f\r
56         2008\r
57         5\r
58         26\r
59         0\r
60         37\r
61         42+2469/20000\r
62         T{ duration f 0 0 0 -5 0 0 }\r
63     }\r
64 ] [ "2008-05-26T00:37:42.12345-05:00" rfc3339>timestamp ] unit-test\r
66 [\r
67     T{ timestamp\r
68         { year 2008 }\r
69         { month 10 }\r
70         { day 2 }\r
71         { hour 23 }\r
72         { minute 59 }\r
73         { second 59 }\r
74         { gmt-offset T{ duration f 0 0 0 0 0 0 } }\r
75     }\r
76 ] [ "Thursday, 02-Oct-2008 23:59:59 GMT" cookie-string>timestamp ] unit-test\r