]> gitweb.factorcode.org Git - factor.git/blob - extra/zoneinfo/zoneinfo-tests.factor
Switch to https urls
[factor.git] / extra / zoneinfo / zoneinfo-tests.factor
1 ! Copyright (C) 2013 Doug Coleman.
2 ! See https://factorcode.org/license.txt for BSD license.
3 USING: accessors assocs calendar kernel math sequences sets
4 tools.test zoneinfo ;
5
6 { t } [ "PST8PDT" find-zone-rules and >boolean ] unit-test
7
8 {
9     T{ raw-zone
10         { name "EST" }
11         { gmt-offset "-5:00" }
12         { rules/save "-" }
13         { format "EST" }
14         { until { } }
15     }
16 } [
17     "EST" find-zone
18 ] unit-test
19
20 {
21     T{ raw-zone
22         { name "Pacific/Kiritimati" }
23         { gmt-offset "14:00" }
24         { rules/save "-" }
25         { format "+14" }
26         { until { } }
27     }
28 } [
29     "Pacific/Kiritimati" timezone>rules last
30 ] unit-test
31
32 ! First and last timezones + 24 hours = length of day
33 { 50 } [
34     now midnight "Etc/GMT+12" find-zone gmt-offset>> hms>duration >>gmt-offset
35     now midnight "Etc/GMT-14" find-zone gmt-offset>> hms>duration >>gmt-offset
36     time- duration>hours 24 +
37 ] unit-test
38
39 ! Make sure we handle # in weird places, like in "Europe/Athens"
40 { } [
41     raw-zone-map values
42     [ [ gmt-offset>> ] map ] map concat members
43     [ hms>duration ] map
44     drop
45 ] unit-test
46