[6.4] move package to toplevel
Because pkgs.racket-lang doesn't seem to accept paths like .../repo.git#branch?tag So I'm trying to remove the ?tag
This commit is contained in:
parent
7ef8e90a41
commit
04835b5339
109
README.md
109
README.md
|
@ -1,104 +1,11 @@
|
|||
trivial
|
||||
===
|
||||
[](https://travis-ci.org/bennn/trivial)
|
||||
[](https://coveralls.io/github/bennn/trivial?branch=master)
|
||||
[](http://pkg-build.racket-lang.org/doc/trivial/index.html)
|
||||
|
||||
This [Typed Racket](http://docs.racket-lang.org/ts-reference/) library provides "smarter" versions of standard library functions.
|
||||
For example:
|
||||
|
||||
```
|
||||
#lang typed/racket/base
|
||||
|
||||
(require trivial)
|
||||
|
||||
(printf: "hello, ~a")
|
||||
|
||||
;; > raco make test.rkt
|
||||
;; format:: arity mismatch;
|
||||
;; the expected number of arguments does not match the given number
|
||||
;; expected: 1
|
||||
;; given: 0
|
||||
```
|
||||
|
||||
The `printf:` (with a colon) checks whether its first argument is a string literal.
|
||||
If so, it parses the string's format sequences for arity and type constraints.
|
||||
|
||||
Definitions work too:
|
||||
|
||||
```
|
||||
(require trivial/no-colon)
|
||||
|
||||
(let ([s "hello ~a"])
|
||||
(printf s))
|
||||
|
||||
```
|
||||
|
||||
|
||||
When the first argument to `printf:` is not clear from the program syntax, nothing special happens; we just call the standard `printf`.
|
||||
|
||||
```
|
||||
#lang typed/racket/base
|
||||
|
||||
(require trivial)
|
||||
|
||||
((lambda ([s : String])
|
||||
(printf: s)) ;; Non-trivial!
|
||||
"hello, ~a\n")
|
||||
|
||||
;; Compiles successfully, but throws arity error at runtime
|
||||
```
|
||||
|
||||
Besides `printf:`, this library also provides [macros](http://www.greghendershott.com/fear-of-macros/)
|
||||
for:
|
||||
|
||||
- `regexp-match:`, to count the number of groups in a pattern and give the match result a more specific type
|
||||
- constant-folding arithmetic, so `(/ 1 0)` raises a compile-time error
|
||||
- arity-aware functions, like generalized `curry` and `map`
|
||||
- size-aware vector functions, like length-propagating `vector-append`
|
||||
- (experimental) typed database queries
|
||||
|
||||
See the [documentation](http://pkg-build.racket-lang.org/doc/trivial/index.html) for the full story.
|
||||
|
||||
`trivial` is not currently compatible with untyped Racket.
|
||||
|
||||
|
||||
Install
|
||||
Project Structure
|
||||
---
|
||||
|
||||
From Github:
|
||||
|
||||
```
|
||||
> git clone https://github.com/bennn/trivial
|
||||
> raco pkg install ./trivial
|
||||
```
|
||||
|
||||
From the Racket [package server](http://pkgs.racket-lang.org/):
|
||||
|
||||
```
|
||||
> raco pkg install trivial
|
||||
```
|
||||
|
||||
Use `(require trivial)` to import all bindings from this library.
|
||||
If you get tired of writing colons everywhere, require `trivial/no-colon` instead.
|
||||
|
||||
|
||||
Naming
|
||||
---
|
||||
|
||||
- The library is "trivial" because it solves only the simplest typechecking problems, and does so simply by analyzing a local chunk of source code.
|
||||
|
||||
- By convention, we suffix all our exports with a trailing colon.
|
||||
This is a hint that the macro will attempt some extra static analysis (including typechecking) at its call-site.
|
||||
|
||||
|
||||
Contributing
|
||||
---
|
||||
|
||||
The perfect feature request would start like:
|
||||
|
||||
"Typed Racket rejects this program, but it is obviously well-typed because ..."
|
||||
|
||||
If the right type really is obvious, syntactically, we'll extend this library.
|
||||
|
||||
- `private/` Contains the implementation
|
||||
- `scribblings/` Documentation sources
|
||||
- `info.rkt` Racket package metadata
|
||||
- `main.rkt` Package front-end, use with `(require trivial)`
|
||||
- `no-colon.rkt` Alternate front-end, use with `(require trivial/no-colon)`
|
||||
- `*.rkt` Front-ends for specific libraries
|
||||
- `*/` Front-ends for the no-colon versions of specific libraries, like `(require format/no-colon)`
|
||||
|
||||
|
|
9
icfp-2016/.gitignore
vendored
9
icfp-2016/.gitignore
vendored
|
@ -1,9 +0,0 @@
|
|||
*.aux
|
||||
*.bbl
|
||||
*.blg
|
||||
*.cls
|
||||
*.log
|
||||
*.out
|
||||
*.pdf
|
||||
paper.tex
|
||||
pearl.tex
|
|
@ -1,22 +0,0 @@
|
|||
PAPER=pearl
|
||||
|
||||
all: pearl.pdf
|
||||
|
||||
compiled/pearl_scrbl.zo: *.rkt *.scrbl
|
||||
raco make -v $(PAPER).scrbl
|
||||
|
||||
pearl.pdf: pkg compiled/pearl_scrbl.zo texstyle.tex
|
||||
scribble ++extra fig-experience.tex ++extra fig-stxclass.tex ++extra fig-stats.tex ++style texstyle.tex --pdf $(PAPER).scrbl
|
||||
|
||||
pearl.tex: pkg compiled/pearl_scrbl.zo texstyle.tex
|
||||
scribble ++style texstyle.tex --latex $(PAPER).scrbl
|
||||
|
||||
pkg:
|
||||
raco pkg install --skip-installed trivial
|
||||
|
||||
teaser:
|
||||
xelatex teaser.tex
|
||||
|
||||
clean:
|
||||
rm -r compiled
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
trivial @ icfp 2016, hopefully
|
||||
---
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
benchmark
|
||||
===
|
||||
|
||||
Format
|
||||
---
|
||||
|
||||
- Benchmark gets dedicated folder
|
||||
- 2 required folders inside benchmark folder
|
||||
- `pre` : code without `trivial`
|
||||
- `post` : code after adding `trivial`
|
||||
- 1 optional folder
|
||||
- `base` : contains shared data files
|
||||
|
||||
|
||||
Test Cases
|
||||
---
|
||||
|
||||
|
||||
|
||||
Changes
|
||||
---
|
||||
(Anything to get it to typecheck?)
|
||||
|
||||
- fsm : changed a few defines
|
||||
automata.rkt
|
||||
46:(define: COOPERATE 0)
|
||||
48:(define: DEFECT 1)
|
||||
163:(define: PAYOFF-TABLE
|
||||
|
||||
population.rkt
|
||||
42:(define: DEF-COO 2)
|
||||
- gregor : a few arithmetic constants
|
||||
- hyphenate : 1 set!, ignored the import
|
||||
hyphenate.rkt
|
||||
51:(define: default-min-length 5)
|
||||
52:(define: default-min-left-length 2)
|
||||
53:(define: default-min-right-length 2)
|
||||
54:(define: default-joiner #\u00AD)
|
||||
- modulegraph : simplified some regexp matching, no more dev assertions
|
||||
- morse-code : 1 set!, 12 lines (just ignored the import)
|
||||
removed an annotation on regexp-match
|
||||
- suffixtree : 2 set! to set-box!, 6 lines affected
|
||||
- synth : had to remove racket/vector imports
|
||||
|
||||
|
||||
|
||||
Other
|
||||
---
|
||||
|
||||
shootout was a failure, the code is a little too weird
|
|
@ -1,21 +0,0 @@
|
|||
#lang typed/racket/base
|
||||
(require trivial/no-colon)
|
||||
|
||||
(define-type Probability Nonnegative-Real)
|
||||
(define-type Population (cons Automaton* Automaton*))
|
||||
(define-type Automaton* [Vectorof Automaton])
|
||||
(define-type Payoff Nonnegative-Real)
|
||||
|
||||
(define-type State Natural)
|
||||
(define-type Transition* [Vectorof Transition])
|
||||
(define-type Transition [Vectorof State])
|
||||
|
||||
(require "automata.rkt"
|
||||
)
|
||||
|
||||
(provide
|
||||
defects cooperates tit-for-tat grim-trigger match-pair automaton-reset clone
|
||||
make-random-automaton
|
||||
automaton-payoff
|
||||
Automaton
|
||||
Probability Population Automaton* Payoff)
|
|
@ -1,169 +0,0 @@
|
|||
#lang typed/racket
|
||||
(require trivial/no-colon)
|
||||
|
||||
;; An N-states, N-inputs Automaton
|
||||
|
||||
(define-type Automaton automaton)
|
||||
(define-type Payoff Nonnegative-Real)
|
||||
|
||||
(provide
|
||||
defects
|
||||
cooperates
|
||||
tit-for-tat
|
||||
grim-trigger
|
||||
make-random-automaton
|
||||
match-pair
|
||||
automaton-reset
|
||||
clone
|
||||
automaton-payoff
|
||||
;; --
|
||||
Automaton
|
||||
;Payoff
|
||||
)
|
||||
(: defects (-> Payoff Automaton))
|
||||
(: cooperates (-> Payoff Automaton))
|
||||
(: tit-for-tat (-> Payoff Automaton))
|
||||
(: grim-trigger (-> Payoff Automaton))
|
||||
(: make-random-automaton
|
||||
;; (make-random-automaton n) builds an n states x n inputs automaton
|
||||
;; with a random transition table
|
||||
(-> Natural Automaton))
|
||||
|
||||
(: match-pair
|
||||
;; give each automaton the reaction of the other in the current state
|
||||
;; determine payoff for each and transition the automaton
|
||||
(-> Automaton Automaton Natural (values Automaton Automaton)))
|
||||
|
||||
(: automaton-reset
|
||||
;; wipe out the historic payoff, set back to original state
|
||||
(-> Automaton Automaton))
|
||||
(: clone
|
||||
;; create new automaton from given one (same original state)
|
||||
(-> Automaton Automaton))
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
(: COOPERATE State)
|
||||
(define COOPERATE 0)
|
||||
(: DEFECT State)
|
||||
(define DEFECT 1)
|
||||
|
||||
(define-type State Natural)
|
||||
(define-type Transition* [Vectorof Transition])
|
||||
(define-type Transition [Vectorof State])
|
||||
|
||||
(struct automaton ({current : State}
|
||||
{original : State}
|
||||
{payoff : Payoff}
|
||||
{table : Transition*}) #:transparent)
|
||||
|
||||
(define (make-random-automaton n)
|
||||
(: transitions [-> Any Transition])
|
||||
(define (transitions _i) (build-vector n (lambda (_) (random n))))
|
||||
(define original-current (random n))
|
||||
(automaton original-current original-current 0 (build-vector n transitions)))
|
||||
|
||||
(: make-automaton (-> State Transition* Automaton))
|
||||
(define (make-automaton current table)
|
||||
(automaton current current 0 table))
|
||||
|
||||
(: transitions (-> #:i-cooperate/it-cooperates State
|
||||
#:i-cooperate/it-defects State
|
||||
#:i-defect/it-cooperates State
|
||||
#:i-defect/it-defects State
|
||||
Transition*))
|
||||
(define (transitions #:i-cooperate/it-cooperates cc
|
||||
#:i-cooperate/it-defects cd
|
||||
#:i-defect/it-cooperates dc
|
||||
#:i-defect/it-defects dd)
|
||||
(vector (vector cc cd)
|
||||
(vector dc dd)))
|
||||
|
||||
;; CLASSIC AUTOMATA
|
||||
;; the all defector has 2 states of cooperate and defect
|
||||
;; but it always defects, no matter what
|
||||
;; the opponent may play cooperate or defect
|
||||
;; it doesnt care, it always stay in the state defect
|
||||
|
||||
(define defect-transitions
|
||||
(transitions #:i-cooperate/it-cooperates DEFECT
|
||||
#:i-cooperate/it-defects DEFECT
|
||||
#:i-defect/it-cooperates DEFECT
|
||||
#:i-defect/it-defects DEFECT))
|
||||
|
||||
(define (defects p0)
|
||||
(automaton DEFECT DEFECT p0 defect-transitions))
|
||||
|
||||
(define cooperates-transitions
|
||||
(transitions #:i-cooperate/it-cooperates COOPERATE
|
||||
#:i-cooperate/it-defects COOPERATE
|
||||
#:i-defect/it-cooperates COOPERATE
|
||||
#:i-defect/it-defects COOPERATE))
|
||||
|
||||
(define (cooperates p0)
|
||||
(automaton COOPERATE COOPERATE p0 cooperates-transitions))
|
||||
|
||||
;; the tit for tat starts out optimistic, it cooperates initially
|
||||
;; however, if the opponent defects, it punishes by switching to defecting
|
||||
;; if the opponent cooperates, it returns to play cooperate again
|
||||
|
||||
(define tit-for-tat-transitions
|
||||
(transitions #:i-cooperate/it-cooperates COOPERATE
|
||||
#:i-cooperate/it-defects DEFECT
|
||||
#:i-defect/it-cooperates COOPERATE
|
||||
#:i-defect/it-defects DEFECT))
|
||||
|
||||
|
||||
(define (tit-for-tat p0)
|
||||
(automaton COOPERATE COOPERATE p0 tit-for-tat-transitions))
|
||||
|
||||
;; the grim trigger also starts out optimistic,
|
||||
;; but the opponent defects for just once then
|
||||
;; it jumps to defect forever
|
||||
;; it doesnt forgive, and doesnt forget
|
||||
|
||||
(define grim-transitions
|
||||
(transitions #:i-cooperate/it-cooperates COOPERATE
|
||||
#:i-cooperate/it-defects DEFECT
|
||||
#:i-defect/it-cooperates DEFECT
|
||||
#:i-defect/it-defects DEFECT))
|
||||
|
||||
(: grim-trigger (-> Payoff Automaton))
|
||||
(define (grim-trigger p0)
|
||||
(automaton COOPERATE COOPERATE p0 grim-transitions))
|
||||
|
||||
(define (automaton-reset a)
|
||||
(match-define (automaton current c0 payoff table) a)
|
||||
(automaton c0 c0 0 table))
|
||||
|
||||
(define (clone a)
|
||||
(match-define (automaton current c0 payoff table) a)
|
||||
(automaton c0 c0 0 table))
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
;; the sum of pay-offs for the two respective automata over all rounds
|
||||
|
||||
(define (match-pair auto1 auto2 rounds-per-match)
|
||||
(match-define (automaton current1 c1 payoff1 table1) auto1)
|
||||
(match-define (automaton current2 c2 payoff2 table2) auto2)
|
||||
(define-values (new1 p1 new2 p2)
|
||||
(for/fold ([current1 : State current1]
|
||||
[payoff1 : Payoff payoff1]
|
||||
[current2 : State current2]
|
||||
[payoff2 : Payoff payoff2])
|
||||
([_ (in-range rounds-per-match)])
|
||||
(match-define (cons p1 p2) (payoff current1 current2))
|
||||
(define n1 (vector-ref (vector-ref table1 current1) current2))
|
||||
(define n2 (vector-ref (vector-ref table2 current2) current1))
|
||||
(values n1 (+ payoff1 p1) n2 (+ payoff2 p2))))
|
||||
(values (automaton new1 c1 p1 table1) (automaton new2 c2 p2 table2)))
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
;; PayoffTable = [Vectorof k [Vectorof k (cons Payoff Payoff)]]
|
||||
(: PAYOFF-TABLE [Vectorof [Vectorof (cons Payoff Payoff)]])
|
||||
(define PAYOFF-TABLE
|
||||
(vector (vector (cons 3 3) (cons 0 4))
|
||||
(vector (cons 4 0) (cons 1 1))))
|
||||
|
||||
(: payoff (-> State State [cons Payoff Payoff]))
|
||||
(define (payoff current1 current2)
|
||||
(vector-ref (vector-ref PAYOFF-TABLE current1) current2))
|
|
@ -1,48 +0,0 @@
|
|||
#lang typed/racket
|
||||
(require trivial/no-colon)
|
||||
|
||||
;; Run a Simulation of Interacting Automata
|
||||
(random-seed 7480)
|
||||
|
||||
;; =============================================================================
|
||||
(require
|
||||
"automata-adapted.rkt")
|
||||
(require "population.rkt"
|
||||
)
|
||||
(require "utilities.rkt"
|
||||
)
|
||||
|
||||
;; effect: run timed simulation, create and display plot of average payoffs
|
||||
;; effect: measure time needed for the simulation
|
||||
(define (main)
|
||||
(simulation->lines
|
||||
(evolve (build-random-population 100) 1000 10 20))
|
||||
(void))
|
||||
|
||||
(: simulation->lines (-> [Listof Payoff] [Listof [List Integer Real]]))
|
||||
;; turn average payoffs into a list of Cartesian points
|
||||
(define (simulation->lines data)
|
||||
(for/list : [Listof [List Integer Real]]
|
||||
([d : Payoff (in-list data)][n : Integer (in-naturals)])
|
||||
(list n d)))
|
||||
|
||||
(: evolve (-> Population Natural Natural Natural [Listof Payoff]))
|
||||
;; computes the list of average payoffs over the evolution of population p for
|
||||
;; c cycles of of match-ups with r rounds per match and at birth/death rate of s
|
||||
(define (evolve p c s r)
|
||||
(cond
|
||||
[(zero? c) '()]
|
||||
[else (define p2 (match-up* p r))
|
||||
;; Note: r is typed as State even though State is not exported
|
||||
(define pp (population-payoffs p2))
|
||||
(define p3 (death-birth p2 s))
|
||||
;; Note: s same as r
|
||||
({inst cons Payoff [Listof Payoff]}
|
||||
(cast (relative-average pp r) Payoff)
|
||||
;; Note: evolve is assigned (-> ... [Listof Probability])
|
||||
;; even though it is explicitly typed ... [Listof Payoff]
|
||||
(evolve p3 (- c 1) s r))]))
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
(time (main))
|
||||
|
|
@ -1,103 +0,0 @@
|
|||
#lang typed/racket
|
||||
(require trivial/no-colon)
|
||||
|
||||
;; Populations of Automata
|
||||
|
||||
(define-type Population (cons Automaton* Automaton*))
|
||||
(define-type Automaton* [Vectorof Automaton])
|
||||
|
||||
(provide
|
||||
build-random-population
|
||||
population-payoffs
|
||||
match-up*
|
||||
death-birth
|
||||
;; ==
|
||||
;Payoff
|
||||
;Population
|
||||
)
|
||||
(: build-random-population
|
||||
;; (build-population n c) for even n, build a population of size n
|
||||
;; with c constraint: (even? n)
|
||||
(-> Natural Population))
|
||||
(: population-payoffs (-> Population [Listof Payoff]))
|
||||
(: match-up*
|
||||
;; (match-ups p r) matches up neighboring pairs of
|
||||
;; automata in population p for r rounds
|
||||
(-> Population Natural Population))
|
||||
(: death-birth
|
||||
;; (death-birth p r) replaces r elements of p with r "children" of
|
||||
;; randomly chosen fittest elements of p, also shuffle
|
||||
;; constraint (< r (length p))
|
||||
(-> Population Natural [#:random (U False Real)] Population))
|
||||
|
||||
;; =============================================================================
|
||||
(require
|
||||
"automata-adapted.rkt")
|
||||
(require "utilities.rkt"
|
||||
)
|
||||
|
||||
;; Population = (Cons Automaton* Automaton*)
|
||||
;; Automaton* = [Vectorof Automaton]
|
||||
|
||||
(define DEF-COO 2)
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
(define (build-random-population n)
|
||||
(define v (build-vector n (lambda (_) (make-random-automaton DEF-COO))))
|
||||
(cons v v))
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
(define (population-payoffs population0)
|
||||
(define population (car population0))
|
||||
(for/list ([a population]) (automaton-payoff a)))
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
|
||||
(define (match-up* population0 rounds-per-match)
|
||||
(define a* (car population0))
|
||||
;; comment out this line if you want cummulative payoff histories:
|
||||
;; see below in birth-death
|
||||
(population-reset a*)
|
||||
;; -- IN --
|
||||
(for ([i (in-range 0 (- (vector-length a*) 1) 2)])
|
||||
(define p1 (vector-ref a* i))
|
||||
(define p2 (vector-ref a* (+ i 1)))
|
||||
(define-values (a1 a2) (match-pair p1 p2 rounds-per-match))
|
||||
(vector-set! a* i a1)
|
||||
(vector-set! a* (+ i 1) a2))
|
||||
population0)
|
||||
|
||||
(: population-reset (-> Automaton* Void))
|
||||
;; effec: reset all automata in a*
|
||||
(define (population-reset a*)
|
||||
(for ([x (in-vector a*)][i (in-naturals)])
|
||||
(vector-set! a* i (automaton-reset x))))
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
|
||||
(define (death-birth population0 rate #:random (q #false))
|
||||
(match-define (cons a* b*) population0)
|
||||
(define payoffs
|
||||
(for/list : [Listof Payoff] ([x : Automaton (in-vector a*)])
|
||||
(automaton-payoff x)))
|
||||
[define substitutes (choose-randomly payoffs rate #:random q)]
|
||||
(for ([i (in-range rate)][p (in-list substitutes)])
|
||||
(vector-set! a* i (clone (vector-ref b* p))))
|
||||
(shuffle-vector a* b*))
|
||||
|
||||
(: shuffle-vector
|
||||
(All (X) (-> (Vectorof X) (Vectorof X) (cons (Vectorof X) (Vectorof X)))))
|
||||
;; effect: shuffle vector b into vector a
|
||||
;; constraint: (= (vector-length a) (vector-length b))
|
||||
;; Fisher-Yates Shuffle
|
||||
|
||||
(define (shuffle-vector b a)
|
||||
;; copy b into a
|
||||
(for ([x (in-vector b)][i (in-naturals)])
|
||||
(vector-set! a i x))
|
||||
;; now shuffle a
|
||||
(for ([x (in-vector b)] [i (in-naturals)])
|
||||
(define j (random (add1 i)))
|
||||
(unless (= j i) (vector-set! a i (vector-ref a j)))
|
||||
(vector-set! a j x))
|
||||
(cons a b))
|
|
@ -1,58 +0,0 @@
|
|||
#lang typed/racket
|
||||
(require trivial/no-colon)
|
||||
|
||||
;; Utility Functions
|
||||
|
||||
(define-type Probability Nonnegative-Real)
|
||||
;; constraint [0,1]
|
||||
|
||||
(provide
|
||||
;Probability
|
||||
;; ---
|
||||
sum
|
||||
relative-average
|
||||
choose-randomly)
|
||||
|
||||
(: sum (-> [Listof Real] Real))
|
||||
(: relative-average (-> [Listof Real] Real Real))
|
||||
(: choose-randomly
|
||||
(-> [Listof Probability] Natural [#:random (U False Real)] [Listof Natural]))
|
||||
|
||||
;; =============================================================================
|
||||
|
||||
(define (sum l)
|
||||
(apply + l))
|
||||
|
||||
|
||||
(define (relative-average l w)
|
||||
(exact->inexact
|
||||
(/ (sum l)
|
||||
w (length l))))
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
|
||||
(define (choose-randomly probabilities speed #:random (q #false))
|
||||
(define %s (accumulated-%s probabilities))
|
||||
(for/list ([n (in-range speed)])
|
||||
[define r (or q (random))]
|
||||
;; population is non-empty so there will be some i such that ...
|
||||
(let loop : Natural ([%s : [Listof Real] %s])
|
||||
(cond
|
||||
[(< r (first %s)) 0]
|
||||
[else (add1 (loop (rest %s)))]))
|
||||
#;
|
||||
(for/last ([p (in-naturals)] [% (in-list %s)] #:final (< r %)) p)))
|
||||
|
||||
(: accumulated-%s (-> [Listof Probability] [Listof Real]))
|
||||
;; [Listof Probability] -> [Listof Probability]
|
||||
;; calculate the accumulated probabilities
|
||||
|
||||
(define (accumulated-%s probabilities)
|
||||
(define total (sum probabilities))
|
||||
(let relative->absolute : [Listof Real]
|
||||
([payoffs : [Listof Real] probabilities][so-far : Real #i0.0])
|
||||
(cond
|
||||
[(empty? payoffs) '()]
|
||||
[else (define nxt (+ so-far (first payoffs)))
|
||||
({inst cons Real Real}
|
||||
(/ nxt total) (relative->absolute (rest payoffs) nxt))])))
|
|
@ -1,20 +0,0 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
(define-type Probability Nonnegative-Real)
|
||||
(define-type Population (cons Automaton* Automaton*))
|
||||
(define-type Automaton* [Vectorof Automaton])
|
||||
(define-type Payoff Nonnegative-Real)
|
||||
|
||||
(define-type State Natural)
|
||||
(define-type Transition* [Vectorof Transition])
|
||||
(define-type Transition [Vectorof State])
|
||||
|
||||
(require "automata.rkt"
|
||||
)
|
||||
|
||||
(provide
|
||||
defects cooperates tit-for-tat grim-trigger match-pair automaton-reset clone
|
||||
make-random-automaton
|
||||
automaton-payoff
|
||||
Automaton
|
||||
Probability Population Automaton* Payoff)
|
|
@ -1,168 +0,0 @@
|
|||
#lang typed/racket
|
||||
|
||||
;; An N-states, N-inputs Automaton
|
||||
|
||||
(define-type Automaton automaton)
|
||||
(define-type Payoff Nonnegative-Real)
|
||||
|
||||
(provide
|
||||
defects
|
||||
cooperates
|
||||
tit-for-tat
|
||||
grim-trigger
|
||||
make-random-automaton
|
||||
match-pair
|
||||
automaton-reset
|
||||
clone
|
||||
automaton-payoff
|
||||
;; --
|
||||
Automaton
|
||||
;Payoff
|
||||
)
|
||||
(: defects (-> Payoff Automaton))
|
||||
(: cooperates (-> Payoff Automaton))
|
||||
(: tit-for-tat (-> Payoff Automaton))
|
||||
(: grim-trigger (-> Payoff Automaton))
|
||||
(: make-random-automaton
|
||||
;; (make-random-automaton n) builds an n states x n inputs automaton
|
||||
;; with a random transition table
|
||||
(-> Natural Automaton))
|
||||
|
||||
(: match-pair
|
||||
;; give each automaton the reaction of the other in the current state
|
||||
;; determine payoff for each and transition the automaton
|
||||
(-> Automaton Automaton Natural (values Automaton Automaton)))
|
||||
|
||||
(: automaton-reset
|
||||
;; wipe out the historic payoff, set back to original state
|
||||
(-> Automaton Automaton))
|
||||
(: clone
|
||||
;; create new automaton from given one (same original state)
|
||||
(-> Automaton Automaton))
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
(: COOPERATE State)
|
||||
(define COOPERATE 0)
|
||||
(: DEFECT State)
|
||||
(define DEFECT 1)
|
||||
|
||||
(define-type State Natural)
|
||||
(define-type Transition* [Vectorof Transition])
|
||||
(define-type Transition [Vectorof State])
|
||||
|
||||
(struct automaton ({current : State}
|
||||
{original : State}
|
||||
{payoff : Payoff}
|
||||
{table : Transition*}) #:transparent)
|
||||
|
||||
(define (make-random-automaton n)
|
||||
(: transitions [-> Any Transition])
|
||||
(define (transitions _i) (build-vector n (lambda (_) (random n))))
|
||||
(define original-current (random n))
|
||||
(automaton original-current original-current 0 (build-vector n transitions)))
|
||||
|
||||
(: make-automaton (-> State Transition* Automaton))
|
||||
(define (make-automaton current table)
|
||||
(automaton current current 0 table))
|
||||
|
||||
(: transitions (-> #:i-cooperate/it-cooperates State
|
||||
#:i-cooperate/it-defects State
|
||||
#:i-defect/it-cooperates State
|
||||
#:i-defect/it-defects State
|
||||
Transition*))
|
||||
(define (transitions #:i-cooperate/it-cooperates cc
|
||||
#:i-cooperate/it-defects cd
|
||||
#:i-defect/it-cooperates dc
|
||||
#:i-defect/it-defects dd)
|
||||
(vector (vector cc cd)
|
||||
(vector dc dd)))
|
||||
|
||||
;; CLASSIC AUTOMATA
|
||||
;; the all defector has 2 states of cooperate and defect
|
||||
;; but it always defects, no matter what
|
||||
;; the opponent may play cooperate or defect
|
||||
;; it doesnt care, it always stay in the state defect
|
||||
|
||||
(define defect-transitions
|
||||
(transitions #:i-cooperate/it-cooperates DEFECT
|
||||
#:i-cooperate/it-defects DEFECT
|
||||
#:i-defect/it-cooperates DEFECT
|
||||
#:i-defect/it-defects DEFECT))
|
||||
|
||||
(define (defects p0)
|
||||
(automaton DEFECT DEFECT p0 defect-transitions))
|
||||
|
||||
(define cooperates-transitions
|
||||
(transitions #:i-cooperate/it-cooperates COOPERATE
|
||||
#:i-cooperate/it-defects COOPERATE
|
||||
#:i-defect/it-cooperates COOPERATE
|
||||
#:i-defect/it-defects COOPERATE))
|
||||
|
||||
(define (cooperates p0)
|
||||
(automaton COOPERATE COOPERATE p0 cooperates-transitions))
|
||||
|
||||
;; the tit for tat starts out optimistic, it cooperates initially
|
||||
;; however, if the opponent defects, it punishes by switching to defecting
|
||||
;; if the opponent cooperates, it returns to play cooperate again
|
||||
|
||||
(define tit-for-tat-transitions
|
||||
(transitions #:i-cooperate/it-cooperates COOPERATE
|
||||
#:i-cooperate/it-defects DEFECT
|
||||
#:i-defect/it-cooperates COOPERATE
|
||||
#:i-defect/it-defects DEFECT))
|
||||
|
||||
|
||||
(define (tit-for-tat p0)
|
||||
(automaton COOPERATE COOPERATE p0 tit-for-tat-transitions))
|
||||
|
||||
;; the grim trigger also starts out optimistic,
|
||||
;; but the opponent defects for just once then
|
||||
;; it jumps to defect forever
|
||||
;; it doesnt forgive, and doesnt forget
|
||||
|
||||
(define grim-transitions
|
||||
(transitions #:i-cooperate/it-cooperates COOPERATE
|
||||
#:i-cooperate/it-defects DEFECT
|
||||
#:i-defect/it-cooperates DEFECT
|
||||
#:i-defect/it-defects DEFECT))
|
||||
|
||||
(: grim-trigger (-> Payoff Automaton))
|
||||
(define (grim-trigger p0)
|
||||
(automaton COOPERATE COOPERATE p0 grim-transitions))
|
||||
|
||||
(define (automaton-reset a)
|
||||
(match-define (automaton current c0 payoff table) a)
|
||||
(automaton c0 c0 0 table))
|
||||
|
||||
(define (clone a)
|
||||
(match-define (automaton current c0 payoff table) a)
|
||||
(automaton c0 c0 0 table))
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
;; the sum of pay-offs for the two respective automata over all rounds
|
||||
|
||||
(define (match-pair auto1 auto2 rounds-per-match)
|
||||
(match-define (automaton current1 c1 payoff1 table1) auto1)
|
||||
(match-define (automaton current2 c2 payoff2 table2) auto2)
|
||||
(define-values (new1 p1 new2 p2)
|
||||
(for/fold ([current1 : State current1]
|
||||
[payoff1 : Payoff payoff1]
|
||||
[current2 : State current2]
|
||||
[payoff2 : Payoff payoff2])
|
||||
([_ (in-range rounds-per-match)])
|
||||
(match-define (cons p1 p2) (payoff current1 current2))
|
||||
(define n1 (vector-ref (vector-ref table1 current1) current2))
|
||||
(define n2 (vector-ref (vector-ref table2 current2) current1))
|
||||
(values n1 (+ payoff1 p1) n2 (+ payoff2 p2))))
|
||||
(values (automaton new1 c1 p1 table1) (automaton new2 c2 p2 table2)))
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
;; PayoffTable = [Vectorof k [Vectorof k (cons Payoff Payoff)]]
|
||||
(: PAYOFF-TABLE [Vectorof [Vectorof (cons Payoff Payoff)]])
|
||||
(define PAYOFF-TABLE
|
||||
(vector (vector (cons 3 3) (cons 0 4))
|
||||
(vector (cons 4 0) (cons 1 1))))
|
||||
|
||||
(: payoff (-> State State [cons Payoff Payoff]))
|
||||
(define (payoff current1 current2)
|
||||
(vector-ref (vector-ref PAYOFF-TABLE current1) current2))
|
|
@ -1,47 +0,0 @@
|
|||
#lang typed/racket
|
||||
|
||||
;; Run a Simulation of Interacting Automata
|
||||
(random-seed 7480)
|
||||
|
||||
;; =============================================================================
|
||||
(require
|
||||
"automata-adapted.rkt")
|
||||
(require "population.rkt"
|
||||
)
|
||||
(require "utilities.rkt"
|
||||
)
|
||||
|
||||
;; effect: run timed simulation, create and display plot of average payoffs
|
||||
;; effect: measure time needed for the simulation
|
||||
(define (main)
|
||||
(simulation->lines
|
||||
(evolve (build-random-population 100) 1000 10 20))
|
||||
(void))
|
||||
|
||||
(: simulation->lines (-> [Listof Payoff] [Listof [List Integer Real]]))
|
||||
;; turn average payoffs into a list of Cartesian points
|
||||
(define (simulation->lines data)
|
||||
(for/list : [Listof [List Integer Real]]
|
||||
([d : Payoff (in-list data)][n : Integer (in-naturals)])
|
||||
(list n d)))
|
||||
|
||||
(: evolve (-> Population Natural Natural Natural [Listof Payoff]))
|
||||
;; computes the list of average payoffs over the evolution of population p for
|
||||
;; c cycles of of match-ups with r rounds per match and at birth/death rate of s
|
||||
(define (evolve p c s r)
|
||||
(cond
|
||||
[(zero? c) '()]
|
||||
[else (define p2 (match-up* p r))
|
||||
;; Note: r is typed as State even though State is not exported
|
||||
(define pp (population-payoffs p2))
|
||||
(define p3 (death-birth p2 s))
|
||||
;; Note: s same as r
|
||||
({inst cons Payoff [Listof Payoff]}
|
||||
(cast (relative-average pp r) Payoff)
|
||||
;; Note: evolve is assigned (-> ... [Listof Probability])
|
||||
;; even though it is explicitly typed ... [Listof Payoff]
|
||||
(evolve p3 (- c 1) s r))]))
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
(time (main))
|
||||
|
|
@ -1,102 +0,0 @@
|
|||
#lang typed/racket
|
||||
|
||||
;; Populations of Automata
|
||||
|
||||
(define-type Population (cons Automaton* Automaton*))
|
||||
(define-type Automaton* [Vectorof Automaton])
|
||||
|
||||
(provide
|
||||
build-random-population
|
||||
population-payoffs
|
||||
match-up*
|
||||
death-birth
|
||||
;; ==
|
||||
;Payoff
|
||||
;Population
|
||||
)
|
||||
(: build-random-population
|
||||
;; (build-population n c) for even n, build a population of size n
|
||||
;; with c constraint: (even? n)
|
||||
(-> Natural Population))
|
||||
(: population-payoffs (-> Population [Listof Payoff]))
|
||||
(: match-up*
|
||||
;; (match-ups p r) matches up neighboring pairs of
|
||||
;; automata in population p for r rounds
|
||||
(-> Population Natural Population))
|
||||
(: death-birth
|
||||
;; (death-birth p r) replaces r elements of p with r "children" of
|
||||
;; randomly chosen fittest elements of p, also shuffle
|
||||
;; constraint (< r (length p))
|
||||
(-> Population Natural [#:random (U False Real)] Population))
|
||||
|
||||
;; =============================================================================
|
||||
(require
|
||||
"automata-adapted.rkt")
|
||||
(require "utilities.rkt"
|
||||
)
|
||||
|
||||
;; Population = (Cons Automaton* Automaton*)
|
||||
;; Automaton* = [Vectorof Automaton]
|
||||
|
||||
(define DEF-COO 2)
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
(define (build-random-population n)
|
||||
(define v (build-vector n (lambda (_) (make-random-automaton DEF-COO))))
|
||||
(cons v v))
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
(define (population-payoffs population0)
|
||||
(define population (car population0))
|
||||
(for/list ([a population]) (automaton-payoff a)))
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
|
||||
(define (match-up* population0 rounds-per-match)
|
||||
(define a* (car population0))
|
||||
;; comment out this line if you want cummulative payoff histories:
|
||||
;; see below in birth-death
|
||||
(population-reset a*)
|
||||
;; -- IN --
|
||||
(for ([i (in-range 0 (- (vector-length a*) 1) 2)])
|
||||
(define p1 (vector-ref a* i))
|
||||
(define p2 (vector-ref a* (+ i 1)))
|
||||
(define-values (a1 a2) (match-pair p1 p2 rounds-per-match))
|
||||
(vector-set! a* i a1)
|
||||
(vector-set! a* (+ i 1) a2))
|
||||
population0)
|
||||
|
||||
(: population-reset (-> Automaton* Void))
|
||||
;; effec: reset all automata in a*
|
||||
(define (population-reset a*)
|
||||
(for ([x (in-vector a*)][i (in-naturals)])
|
||||
(vector-set! a* i (automaton-reset x))))
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
|
||||
(define (death-birth population0 rate #:random (q #false))
|
||||
(match-define (cons a* b*) population0)
|
||||
(define payoffs
|
||||
(for/list : [Listof Payoff] ([x : Automaton (in-vector a*)])
|
||||
(automaton-payoff x)))
|
||||
[define substitutes (choose-randomly payoffs rate #:random q)]
|
||||
(for ([i (in-range rate)][p (in-list substitutes)])
|
||||
(vector-set! a* i (clone (vector-ref b* p))))
|
||||
(shuffle-vector a* b*))
|
||||
|
||||
(: shuffle-vector
|
||||
(All (X) (-> (Vectorof X) (Vectorof X) (cons (Vectorof X) (Vectorof X)))))
|
||||
;; effect: shuffle vector b into vector a
|
||||
;; constraint: (= (vector-length a) (vector-length b))
|
||||
;; Fisher-Yates Shuffle
|
||||
|
||||
(define (shuffle-vector b a)
|
||||
;; copy b into a
|
||||
(for ([x (in-vector b)][i (in-naturals)])
|
||||
(vector-set! a i x))
|
||||
;; now shuffle a
|
||||
(for ([x (in-vector b)] [i (in-naturals)])
|
||||
(define j (random (add1 i)))
|
||||
(unless (= j i) (vector-set! a i (vector-ref a j)))
|
||||
(vector-set! a j x))
|
||||
(cons a b))
|
|
@ -1,57 +0,0 @@
|
|||
#lang typed/racket
|
||||
|
||||
;; Utility Functions
|
||||
|
||||
(define-type Probability Nonnegative-Real)
|
||||
;; constraint [0,1]
|
||||
|
||||
(provide
|
||||
;Probability
|
||||
;; ---
|
||||
sum
|
||||
relative-average
|
||||
choose-randomly)
|
||||
|
||||
(: sum (-> [Listof Real] Real))
|
||||
(: relative-average (-> [Listof Real] Real Real))
|
||||
(: choose-randomly
|
||||
(-> [Listof Probability] Natural [#:random (U False Real)] [Listof Natural]))
|
||||
|
||||
;; =============================================================================
|
||||
|
||||
(define (sum l)
|
||||
(apply + l))
|
||||
|
||||
|
||||
(define (relative-average l w)
|
||||
(exact->inexact
|
||||
(/ (sum l)
|
||||
w (length l))))
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
|
||||
(define (choose-randomly probabilities speed #:random (q #false))
|
||||
(define %s (accumulated-%s probabilities))
|
||||
(for/list ([n (in-range speed)])
|
||||
[define r (or q (random))]
|
||||
;; population is non-empty so there will be some i such that ...
|
||||
(let loop : Natural ([%s : [Listof Real] %s])
|
||||
(cond
|
||||
[(< r (first %s)) 0]
|
||||
[else (add1 (loop (rest %s)))]))
|
||||
#;
|
||||
(for/last ([p (in-naturals)] [% (in-list %s)] #:final (< r %)) p)))
|
||||
|
||||
(: accumulated-%s (-> [Listof Probability] [Listof Real]))
|
||||
;; [Listof Probability] -> [Listof Probability]
|
||||
;; calculate the accumulated probabilities
|
||||
|
||||
(define (accumulated-%s probabilities)
|
||||
(define total (sum probabilities))
|
||||
(let relative->absolute : [Listof Real]
|
||||
([payoffs : [Listof Real] probabilities][so-far : Real #i0.0])
|
||||
(cond
|
||||
[(empty? payoffs) '()]
|
||||
[else (define nxt (+ so-far (first payoffs)))
|
||||
({inst cons Real Real}
|
||||
(/ nxt total) (relative->absolute (rest payoffs) nxt))])))
|
|
@ -1,104 +0,0 @@
|
|||
#lang racket/base
|
||||
|
||||
(require racket/contract/base
|
||||
racket/runtime-path
|
||||
racket/set
|
||||
json
|
||||
"file.rkt")
|
||||
|
||||
(define cldr-main/c (-> string? jsexpr?))
|
||||
(define cldr-supplemental/c (-> jsexpr?))
|
||||
(define cldr-key/c (or/c symbol? string? integer?
|
||||
(listof (or/c symbol? string? integer?))))
|
||||
|
||||
(provide/contract
|
||||
[cldr-json (-> path? string? path? cldr-key/c jsexpr?)]
|
||||
[cldr-ref (->* [jsexpr? cldr-key/c] [any/c] any/c)]
|
||||
[available-locales (-> (listof string?))]
|
||||
[modern-locales (-> (listof string?))]
|
||||
[all-locales (-> (listof string?))]
|
||||
[modern-locale? (-> string? boolean?)]
|
||||
[locale? (-> string? boolean?)]
|
||||
[raise-locale-not-found (-> string? string? any/c)]
|
||||
[cldr-ref* (->i ([json jsexpr?]
|
||||
#:fail [failure-result any/c])
|
||||
#:rest [keys (listof cldr-key/c)]
|
||||
[result any/c])])
|
||||
|
||||
(provide (struct-out exn:cldr)
|
||||
(struct-out exn:cldr:locale-not-found)
|
||||
cldr-main/c
|
||||
cldr-supplemental/c)
|
||||
|
||||
(struct exn:cldr exn:fail () #:transparent)
|
||||
(struct exn:cldr:locale-not-found exn:cldr (locale pkg) #:transparent)
|
||||
|
||||
(define (raise-locale-not-found loc pkg)
|
||||
(raise (exn:cldr:locale-not-found
|
||||
(format "locale \"~a\" is not in package: ~a" loc pkg)
|
||||
(current-continuation-marks)
|
||||
loc
|
||||
pkg)))
|
||||
|
||||
(define (available-locales)
|
||||
(cldr-json ZIP-PATH PKG "availableLocales.json" 'availableLocales))
|
||||
|
||||
(define (modern-locales)
|
||||
(cldr-ref (available-locales) 'modern))
|
||||
|
||||
(define (all-locales)
|
||||
(cldr-ref (available-locales) 'full))
|
||||
|
||||
(define (modern-locale? loc)
|
||||
(set-member? (modern-locales) loc))
|
||||
|
||||
(define (locale? loc)
|
||||
(set-member? (all-locales) loc))
|
||||
|
||||
(define-syntax-rule (get filename prefix)
|
||||
(λ ()
|
||||
(cldr-json ZIP-PATH
|
||||
PKG
|
||||
(build-path "supplemental" filename)
|
||||
(cons 'supplemental prefix))))
|
||||
|
||||
(define-syntax-rule (defsection name filename path)
|
||||
(begin
|
||||
(define name (get filename path))
|
||||
(provide/contract [name cldr-supplemental/c])))
|
||||
|
||||
(defsection aliases "aliases.json" '(metadata alias))
|
||||
(defsection calendar-data "calendarData.json" '(calendarData))
|
||||
(defsection calendar-preference-data "calendarPreferenceData.json" '(calendarPreferenceData))
|
||||
(defsection character-fallbacks "characterFallbacks.json" '(characters character-fallback))
|
||||
(defsection code-mappings "codeMappings.json" '(codeMappings))
|
||||
(defsection currency-data "currencyData.json" '(currencyData))
|
||||
(defsection gender "gender.json" '(gender))
|
||||
(defsection language-data "languageData.json" '(languageData))
|
||||
(defsection language-matching "languageMatching.json" '(languageMatching))
|
||||
(defsection likely-subtags "likelySubtags.json" '(likelySubtags))
|
||||
(defsection measurement-data "measurementData.json" '(measurementData))
|
||||
(defsection meta-zones "metaZones.json" '(metaZones))
|
||||
(defsection numbering-systems "numberingSystems.json" '(numberingSystems))
|
||||
(defsection ordinals "ordinals.json" '(plurals-type-ordinal))
|
||||
(defsection parent-locales "parentLocales.json" '(parentLocales parentLocale))
|
||||
(defsection plurals "plurals.json" '(plurals-type-cardinal))
|
||||
(defsection postal-code-data "postalCodeData.json" '(postalCodeData))
|
||||
(defsection primary-zones "primaryZones.json" '(primaryZones))
|
||||
(defsection references "references.json" '(references))
|
||||
(defsection telephone-code-data "telephoneCodeData.json" '(telephoneCodeData))
|
||||
(defsection territory-containment "territoryContainment.json" '(territoryContainment))
|
||||
(defsection territory-info "territoryInfo.json" '(territoryInfo))
|
||||
(defsection time-data "timeData.json" '(timeData))
|
||||
(defsection week-data "weekData.json" '(weekData))
|
||||
(defsection windows-zones "windowsZones.json" '(windowsZones mapTimezones))
|
||||
|
||||
|
||||
(define (modern-locale-set)
|
||||
(list->set (modern-locales)))
|
||||
|
||||
(define (all-locale-set)
|
||||
(list->set (all-locales)))
|
||||
|
||||
(define PKG "cldr-core")
|
||||
(define-runtime-path ZIP-PATH "data/cldr-core.zip")
|
Binary file not shown.
|
@ -1,80 +0,0 @@
|
|||
#lang racket/base
|
||||
|
||||
(require racket/dict
|
||||
racket/match
|
||||
racket/port
|
||||
racket/runtime-path
|
||||
file/unzip
|
||||
json)
|
||||
|
||||
(provide cldr-ref
|
||||
cldr-ref*
|
||||
cldr-json)
|
||||
|
||||
(define (cldr-ref json key [fail (λ ()
|
||||
(raise (exn:fail:contract
|
||||
(format "cldr-ref: no value found for key\n\tkey : ~s" key)
|
||||
(current-continuation-marks))))])
|
||||
(define (return/fail) (if (procedure? fail) (fail) fail))
|
||||
|
||||
(cond [(list? key)
|
||||
(let loop ([json json] [key key])
|
||||
(match key
|
||||
[(cons k key)
|
||||
(match (dict-ref json (symbolize-key k) #f)
|
||||
[#f (return/fail)]
|
||||
[j (loop j key)])]
|
||||
[(list) json]))]
|
||||
[else
|
||||
(dict-ref json (symbolize-key key) fail)]))
|
||||
|
||||
(define (cldr-ref* #:fail fail json . keys)
|
||||
(or
|
||||
(for*/first ([key (in-list keys)]
|
||||
[res (in-value (cldr-ref json key #f))]
|
||||
#:when res)
|
||||
res)
|
||||
(if (procedure? fail)
|
||||
(fail)
|
||||
fail)))
|
||||
|
||||
(define (cldr-json zip-path pkg path prefix #:cache? [cache? #t])
|
||||
(define ref (if cache? hash-ref! hash-ref))
|
||||
|
||||
(ref JSON-CACHE
|
||||
path
|
||||
(λ ()
|
||||
(cldr-ref
|
||||
(load-json zip-path (build-path pkg path))
|
||||
prefix))))
|
||||
|
||||
(define (symbolize-key k)
|
||||
(cond [(symbol? k) k]
|
||||
[(string? k) (string->symbol k)]
|
||||
[(integer? k) (string->symbol (number->string k))]))
|
||||
|
||||
(define (load-json zip-path data-path)
|
||||
(call-with-input-file* zip-path
|
||||
(λ (in)
|
||||
(define zip-path (path->zip-path data-path))
|
||||
(define dir (read-zip-directory in))
|
||||
|
||||
(unless (zip-directory-contains? dir zip-path)
|
||||
(error
|
||||
(format "CLDR file not found: ~a" zip-path)))
|
||||
|
||||
(define-values (pipe-in pipe-out) (make-pipe))
|
||||
(define reader (make-extracting-entry-reader pipe-out zip-path))
|
||||
(unzip-entry in dir zip-path reader)
|
||||
(read-json pipe-in))))
|
||||
|
||||
(define (make-extracting-entry-reader out zip-path)
|
||||
(λ (name dir? in)
|
||||
(when dir?
|
||||
(error
|
||||
(format "CLDR path names a directory, not a file: ~a" zip-path)))
|
||||
|
||||
(copy-port in out)))
|
||||
|
||||
|
||||
(define JSON-CACHE (make-hash))
|
|
@ -1,3 +0,0 @@
|
|||
#lang info
|
||||
|
||||
(define scribblings '(("scribblings/cldr-core.scrbl" ())))
|
|
@ -1,102 +0,0 @@
|
|||
#lang racket/base
|
||||
|
||||
(require racket/contract/base
|
||||
racket/match
|
||||
racket/string
|
||||
racket/set
|
||||
memoize)
|
||||
|
||||
(require "core.rkt")
|
||||
|
||||
(struct cldr-locale
|
||||
(lang script region)
|
||||
#:transparent)
|
||||
|
||||
(provide (struct-out cldr-locale))
|
||||
|
||||
(provide/contract
|
||||
[locale->available-cldr-locale (-> string? (-> string? boolean?) string?)]
|
||||
|
||||
[parse-locale (-> string? cldr-locale?)]
|
||||
[locale->cldr-locale (-> string? cldr-locale?)]
|
||||
[locale->cldr-language (-> string? string?)]
|
||||
[locale->cldr-region (-> string? string?)]
|
||||
[locale->cldr-script (-> string? string?)])
|
||||
|
||||
|
||||
(define/memo* (locale->available-cldr-locale locale available?)
|
||||
(define full (locale->cldr-locale locale))
|
||||
|
||||
(for/first ([str (in-list (locale->possible-strings full))]
|
||||
#:when (available? str))
|
||||
str))
|
||||
|
||||
(define (locale->cldr-language str) (cldr-locale-lang (locale->cldr-locale str)))
|
||||
(define (locale->cldr-region str) (cldr-locale-region (locale->cldr-locale str)))
|
||||
(define (locale->cldr-script str) (cldr-locale-script (locale->cldr-locale str)))
|
||||
|
||||
|
||||
(define (locale->cldr-locale str)
|
||||
(hash-ref cldr-locale-cache
|
||||
str
|
||||
(λ ()
|
||||
(define full (resolve-locale (parse-locale str)))
|
||||
(hash-set! cldr-locale-cache str full)
|
||||
full)))
|
||||
|
||||
(define locale-path-cache (make-hash))
|
||||
(define cldr-locale-cache (make-hash))
|
||||
|
||||
(define (locale->possible-strings l)
|
||||
(match l
|
||||
[(cldr-locale lang script region)
|
||||
(list (format "~a-~a-~a" lang script region)
|
||||
(format "~a-~a" lang region)
|
||||
lang
|
||||
"root")]))
|
||||
|
||||
(define (cldr-database-locale src-locale)
|
||||
(define full (locale->cldr-locale src-locale))
|
||||
(for/first ([str (in-list (locale->possible-strings full))]
|
||||
#:when (set-member? (modern-locales) str))
|
||||
str))
|
||||
|
||||
(define (parse-locale str)
|
||||
(match (string-trim str)
|
||||
[(regexp #px"^([^-_.]+)(?:[-_])([^-_.]+)(?:[-_])([^-_.]+)" (list _ lang script region))
|
||||
(build-locale lang script region)]
|
||||
[(regexp #px"^([^-_.]+)(?:[-_])([^-_.]+)" (list _ lang region))
|
||||
(build-locale lang #f region)]
|
||||
[(regexp #px"^[a-zA-Z]+" (list lang))
|
||||
(build-locale lang #f #f)]
|
||||
[_
|
||||
(build-locale "und" #f #f)]))
|
||||
|
||||
(define (build-locale lang script region)
|
||||
(cldr-locale (and lang (string-downcase lang))
|
||||
(and script (string-titlecase script))
|
||||
(and region (string-upcase region))))
|
||||
|
||||
(define (resolve-locale l)
|
||||
(define (lookup src) (cldr-ref (likely-subtags) src #f))
|
||||
|
||||
(match l
|
||||
[(cldr-locale lang script region)
|
||||
(define likely
|
||||
(parse-locale
|
||||
(or (and lang script region
|
||||
(format "~a-~a-~a" lang script region))
|
||||
(and lang region
|
||||
(lookup (format "~a-~a" lang region)))
|
||||
(and lang script
|
||||
(lookup (format "~a-~a" lang script)))
|
||||
(and lang
|
||||
(lookup (format "~a" lang)))
|
||||
(and script
|
||||
(lookup (format "und-~a" script)))
|
||||
(lookup "und"))))
|
||||
(match likely
|
||||
[(cldr-locale def-lang def-script def-region)
|
||||
(cldr-locale (or (and (not (equal? lang "und")) lang) def-lang)
|
||||
(or script def-script)
|
||||
(or region def-region))])]))
|
|
@ -1,207 +0,0 @@
|
|||
#lang scribble/manual
|
||||
|
||||
@(require scribble/eval
|
||||
(for-label racket/base
|
||||
racket/runtime-path
|
||||
cldr/core
|
||||
cldr/likely-subtags
|
||||
json))
|
||||
@(define the-eval (make-base-eval))
|
||||
@(the-eval '(require cldr/core
|
||||
cldr/likely-subtags))
|
||||
|
||||
@title{CLDR Core}
|
||||
@author[@author+email["Jon Zeppieri" "zeppieri@gmail.com"]]
|
||||
|
||||
@margin-note{
|
||||
@deftech{CLDR} is the @link["http://cldr.unicode.org/"]{Common Locale Data Repository}, a
|
||||
database of localization information published by the Unicode Consortium.
|
||||
}
|
||||
|
||||
The CLDR Core library is a Racket interface to the
|
||||
@link["https://github.com/unicode-cldr/cldr-core"]{cldr-core} JSON distribution published by
|
||||
the Unicode Consortium.
|
||||
|
||||
This package provides functions for:
|
||||
@itemize[
|
||||
@item{enumerating the set of locales supported by CLDR and testing whether a given locale is supported;}
|
||||
@item{accessing CLDR JSON data; and }
|
||||
@item{canonicalizing locale strings and mapping them to the set of supported CLDR locales.}
|
||||
]
|
||||
|
||||
@defmodule[cldr/core]
|
||||
|
||||
|
||||
@section{Locale Support}
|
||||
|
||||
@defproc[(all-locales) (listof string?)]{Returns the list of locales supported by CLDR}
|
||||
|
||||
@defproc[(modern-locales) (listof string?)]{Returns the list of modern locales supported by CLDR.}
|
||||
|
||||
@defproc[(locale? [loc string?]) boolean?]{
|
||||
Returns @racket[#t] if @racket[loc] is in @racket[(all-locales)], @racket[#f] otherwise.
|
||||
|
||||
@examples[#:eval the-eval
|
||||
(locale? "fr")
|
||||
(locale? "yi")
|
||||
]}
|
||||
|
||||
@defproc[(modern-locale? [loc string?]) boolean?]{
|
||||
Returns @racket[#t] if @racket[loc] is in @racket[(moderns-locales)], @racket[#f] otherwise.
|
||||
|
||||
@examples[#:eval the-eval
|
||||
(modern-locale? "fr")
|
||||
(modern-locale? "yi")
|
||||
]}
|
||||
|
||||
@defproc[(available-locales) jsexpr?]{
|
||||
Returns the raw data from the @tt{availableLocales.json} data file.
|
||||
}
|
||||
|
||||
|
||||
@section{Accessing CLDR JSON Data}
|
||||
|
||||
@defproc[(cldr-ref [data jsexpr?]
|
||||
[key cldr-key/c]
|
||||
[fail any/c (λ ()
|
||||
(raise (exn:fail:contract ....)))])
|
||||
any/c]{
|
||||
Looks up the mapping of @racket[key] in @racket[data]. If there is no such mapping,
|
||||
then @racket[fail] determines the result:
|
||||
|
||||
@itemize[
|
||||
@item{If @racket[fail] is a procedure, it is called
|
||||
(through a tail call) with no arguments to produce the result.}
|
||||
@item{Otherwise, @racket[fail] is returned as the result.}
|
||||
]}
|
||||
|
||||
@defproc[(cldr-ref* [data jsexpr?]
|
||||
[#:fail fail any/c (λ ()
|
||||
(raise (exn:fail:contract ....)))]
|
||||
[key cldr-key/c]
|
||||
...)
|
||||
any/c]{
|
||||
Like @racket[cldr-ref], except that any number of keys may be provided. The keys are tried in order,
|
||||
and the value of the first key to be found is returned. If none of the given keys are mapped in
|
||||
@racket[data], then @racket[fail] is used to determine the result, just as in @racket[cldr-ref].
|
||||
}
|
||||
|
||||
@defproc[(cldr-json [path-to-zipfile path?]
|
||||
[package-name string?]
|
||||
[path-within-zipfile path?]
|
||||
[common-prefix cldr-key/c])
|
||||
jsexpr?]{
|
||||
A low-level procedure for accessing raw CLDR data from @tt{.zip} files.
|
||||
This function is useful for implementing packages within the @tech{cldr}
|
||||
collection but is generally @emph{not} useful for users of those packages.
|
||||
|
||||
In order to keep download sizes reasonable (since the CLDR data set is very large),
|
||||
packages in the @tt{cldr} collection keep their data in a @tt{.zip} file named
|
||||
for the package in question. For example, the @racket[cldr-core] package contains a
|
||||
data file named @tt{cldr-core.zip}. This file is a compressed archive of the
|
||||
@link["https://github.com/unicode-cldr/cldr-core"]{official distribution}.
|
||||
|
||||
The @racket[cldr-json] procedure takes:
|
||||
|
||||
@itemize[
|
||||
@item{the path to this zipfile (typically defined within the package using
|
||||
@racket[define-runtime-path]);}
|
||||
@item{the name of the package (which doubles as the name of the zipfile,
|
||||
without the @tt{.zip} extension);}
|
||||
@item{the path within the zipfile to the desired @tt{.json} file; and}
|
||||
@item{a key used to prune the returned JSON data.}
|
||||
]}
|
||||
|
||||
@defproc[(raise-locale-not-found [locale string?]
|
||||
[package-name string?])
|
||||
any/c]{
|
||||
Raises @racket[exn:cldr:locale-not-found], indicating that @racket[locale] is not available
|
||||
in the CLDR data set for the package named by @racket[package-name].
|
||||
|
||||
This function is useful for authors of packages within the @tech{cldr} collection.
|
||||
}
|
||||
|
||||
@defstruct*[(exn:cldr exn:fail) () #:transparent]{
|
||||
A struct type that serves as the base type for all CLDR errors.
|
||||
}
|
||||
|
||||
@defstruct*[(exn:cldr:locale-not-found exn:cldr) ([locale string?] [pkg string?]) #:transparent]{
|
||||
Raised by functions that are given locale strings that cannot be mapped to CLDR locales.
|
||||
}
|
||||
|
||||
@defthing[cldr-key/c flat-contract?]{
|
||||
A contract for lookup keys used by @racket[cldr-ref] and @racket[cldr-ref*]. The contract is defined as:
|
||||
|
||||
@racketblock[
|
||||
(or/c symbol? string? integer?
|
||||
(listof (or/c symbol? string? integer?)))
|
||||
]}
|
||||
|
||||
@defthing[cldr-main/c chaperone-contract?]{
|
||||
A contract for functions that return raw data from the @tt{main} section of the CLDR dataset.
|
||||
Data in the @tt{main} section is per-locale. The contract is defined as:
|
||||
|
||||
@racketblock[
|
||||
(-> string? jsexpr?)
|
||||
]
|
||||
|
||||
The string argument is a locale name.
|
||||
}
|
||||
|
||||
@defthing[cldr/supplemental-c chaperone-contract?]{
|
||||
A contract for functions that return raw data from the @tt{supplemental} section of the CLDR dataset.
|
||||
Data in the @tt{supplemental} section is @emph{not} distributed in a per-locale manner. This contract
|
||||
is defined as:
|
||||
|
||||
@racketblock[
|
||||
(-> jsexpr?)
|
||||
]}
|
||||
|
||||
|
||||
@section{Canonicalizing Locale Strings}
|
||||
|
||||
@defmodule[cldr/likely-subtags]
|
||||
|
||||
This module provides a high-level interface to the data in @tt{likelySubtags.json}, described
|
||||
in the
|
||||
@link["http://www.unicode.org/reports/tr35/tr35-39/tr35.html#Likely_Subtags"]{CLDR specification}.
|
||||
|
||||
@defproc[(locale->available-cldr-locale [locale string?]
|
||||
[available? (-> string? boolean?)])
|
||||
string?]{
|
||||
Returns the best available CLDR locale string corresponding to the given CLDR string.
|
||||
Availability is determined by the given @racket[available?] predicate.
|
||||
|
||||
@examples[#:eval the-eval
|
||||
(locale->available-cldr-locale "gd" locale?)
|
||||
(locale->available-cldr-locale "gd" modern-locale?)
|
||||
]}
|
||||
|
||||
@defproc[(locale->cldr-locale [locale string?])
|
||||
cldr-locale?]{
|
||||
Returns the @racket[cldr-locale] that best matches the given @racket[locale] string.
|
||||
|
||||
@examples[#:eval the-eval
|
||||
(locale->cldr-locale "en")
|
||||
(locale->cldr-locale "ar")
|
||||
(locale->cldr-locale "zh")
|
||||
]}
|
||||
|
||||
@defproc[(locale->cldr-language [locale string?]) string?]{
|
||||
Returns the CLDR language code that best matches the given locale string.
|
||||
Equivalent to @racket[(cldr-locale-lang (locale->cldr-locale locale))].
|
||||
}
|
||||
|
||||
@defproc[(locale->cldr-region [locale string?]) string?]{
|
||||
Returns the CLDR region code that best matches the given locale string.
|
||||
Equivalent to @racket[(cldr-locale-region (locale->cldr-locale locale))].
|
||||
}
|
||||
|
||||
@defproc[(locale->cldr-script [locale string?]) string?]{
|
||||
Returns the CLDR script code that best matches the given locale string.
|
||||
Equivalent to @racket[(cldr-locale-script (locale->cldr-locale locale))].
|
||||
}
|
||||
|
||||
|
||||
@defstruct*[cldr-locale ([lang string?] [script string?] [region string?]) #:transparent]
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
(provide Month)
|
||||
(define-type Month (U 1 2 3 4 5 6 7 8 9 10 11 12))
|
|
@ -1,5 +0,0 @@
|
|||
#lang info
|
||||
|
||||
(define name "TZInfo")
|
||||
(define version "0.2")
|
||||
(define scribblings '(("scribblings/tzinfo.scrbl" ())))
|
|
@ -1,79 +0,0 @@
|
|||
#lang racket/base
|
||||
|
||||
(require racket/contract/base
|
||||
syntax/modresolve)
|
||||
|
||||
(require "private/generics.rkt"
|
||||
"private/structs.rkt"
|
||||
"zoneinfo.rkt")
|
||||
|
||||
;; Load the zoneinfo-data package, if it's installed
|
||||
;; (as it should be on Windows, for example).
|
||||
(define ZONEINFO-DATA #f)
|
||||
;; (and (file-exists? (resolve-module-path 'tzinfo/zoneinfo-data #f))
|
||||
;; (dynamic-require 'tzinfo/zoneinfo-data 'ZONEINFO-DATA)))
|
||||
|
||||
(provide (struct-out tzoffset)
|
||||
(struct-out tzgap)
|
||||
(struct-out tzoverlap)
|
||||
(struct-out exn:fail:tzinfo)
|
||||
(struct-out exn:fail:tzinfo:zone-not-found))
|
||||
|
||||
(define istring/c (and/c string? immutable?))
|
||||
|
||||
(provide/contract
|
||||
[current-tzinfo-source (parameter/c (or/c tzinfo-source? false/c))]
|
||||
[set-default-tzinfo-source-constructor! (-> (-> tzinfo-source?) void?)]
|
||||
[utc-seconds->tzoffset (-> string? real? tzoffset?)]
|
||||
[local-seconds->tzoffset (-> string? real? (or/c tzoffset? tzgap? tzoverlap?))]
|
||||
[all-tzids (-> (listof istring/c))]
|
||||
[tzid-exists? (-> string? boolean?)]
|
||||
[tzid->country-codes (-> string? (listof istring/c))]
|
||||
[country-code->tzids (-> string? (listof istring/c))]
|
||||
[system-tzid (-> (or/c istring/c false/c))])
|
||||
|
||||
(define current-tzinfo-source
|
||||
(make-parameter #f))
|
||||
|
||||
(define (utc-seconds->tzoffset tzid seconds)
|
||||
(seconds->tzoffset/utc (ensure-current-tzinfo-source) tzid seconds))
|
||||
|
||||
(define (local-seconds->tzoffset tzid seconds)
|
||||
(seconds->tzoffset/local (ensure-current-tzinfo-source) tzid seconds))
|
||||
|
||||
(define (all-tzids)
|
||||
(tzinfo->all-tzids (ensure-current-tzinfo-source)))
|
||||
|
||||
(define (tzid-exists? tzid)
|
||||
(tzinfo-has-tzid? (ensure-current-tzinfo-source) tzid))
|
||||
|
||||
(define (tzid->country-codes tzid)
|
||||
(tzinfo-tzid->country-codes (ensure-current-tzinfo-source) tzid))
|
||||
|
||||
(define (country-code->tzids cc)
|
||||
(tzinfo-country-code->tzids (ensure-current-tzinfo-source) cc))
|
||||
|
||||
(define (ensure-current-tzinfo-source)
|
||||
(or (current-tzinfo-source)
|
||||
(let ([src (make-default-tzinfo-source)])
|
||||
(current-tzinfo-source src)
|
||||
src)))
|
||||
|
||||
(define (make-default-tzinfo-source)
|
||||
(default-tzinfo-source-constructor))
|
||||
|
||||
(define (set-default-tzinfo-source-constructor! fn)
|
||||
(set! default-tzinfo-source-constructor fn))
|
||||
|
||||
(define default-tzinfo-source-constructor (λ () (make-zoneinfo-source)))
|
||||
|
||||
(define (system-tzid)
|
||||
(unless memoized-system-tzid
|
||||
(set! memoized-system-tzid
|
||||
(or (detect-system-tzid (ensure-current-tzinfo-source))
|
||||
default-system-tzid)))
|
||||
|
||||
memoized-system-tzid)
|
||||
|
||||
(define memoized-system-tzid #f)
|
||||
(define default-system-tzid "Etc/UTC")
|
|
@ -1,15 +0,0 @@
|
|||
#lang racket/base
|
||||
|
||||
(require racket/generic)
|
||||
|
||||
(provide (all-defined-out))
|
||||
|
||||
(define-generics tzinfo-source
|
||||
(tzinfo->all-tzids tzinfo-source)
|
||||
(tzinfo-has-tzid? tzinfo-source tzid)
|
||||
(tzinfo-tzid->country-codes tzinfo-source tzid)
|
||||
(tzinfo-country-code->tzids tzinfo-source cc)
|
||||
(seconds->tzoffset/utc tzinfo-source tzid seconds)
|
||||
(seconds->tzoffset/local tzinfo-source tzid seconds)
|
||||
(detect-system-tzid tzinfo-source))
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
#lang racket/base
|
||||
|
||||
(provide tzid-from-env)
|
||||
|
||||
(define (tzid-from-env)
|
||||
(getenv "TZ"))
|
|
@ -1,70 +0,0 @@
|
|||
#lang racket/base
|
||||
|
||||
(require racket/file
|
||||
racket/match
|
||||
racket/path
|
||||
racket/string
|
||||
"env.rkt")
|
||||
|
||||
(provide detect-tzid/unix)
|
||||
|
||||
(define (detect-tzid/unix zoneinfo-dir default-zoneinfo-dir all-tzids)
|
||||
(or (tzid-from-env)
|
||||
(and zoneinfo-dir
|
||||
(tzid-from-/etc/localtime zoneinfo-dir default-zoneinfo-dir all-tzids))
|
||||
(tzid-from-/etc/timezone)
|
||||
(tzid-from-/etc/TIMEZONE)
|
||||
(tzid-from-/etc/sysconfig/clock)
|
||||
(tzid-from-/etc/default/init)))
|
||||
|
||||
|
||||
(define (tzid-from-/etc/localtime zoneinfo-dir default-zoneinfo-dir all-tzids)
|
||||
(define /etc/localtime "/etc/localtime")
|
||||
(define base-path (resolve-path zoneinfo-dir))
|
||||
|
||||
(define (find-matching-zone)
|
||||
(define size (file-size /etc/localtime))
|
||||
(define content (file->bytes /etc/localtime))
|
||||
|
||||
(for*/first ([tzid (in-list all-tzids)]
|
||||
[f (in-value (build-path base-path tzid))]
|
||||
#:when (and (= (file-size f) size)
|
||||
(equal? (file->bytes f) content)))
|
||||
tzid))
|
||||
|
||||
(and (file-exists? /etc/localtime)
|
||||
default-zoneinfo-dir
|
||||
(let ([rel (find-relative-path default-zoneinfo-dir (resolve-path /etc/localtime))])
|
||||
(match (explode-path rel)
|
||||
[(cons 'up _) (find-matching-zone)]
|
||||
[_ (path->string rel)]))))
|
||||
|
||||
(define (tzid-from-/etc/timezone)
|
||||
(define /etc/timezone "/etc/timezone")
|
||||
|
||||
(and (file-exists? /etc/timezone)
|
||||
(string-trim (file->string /etc/timezone))))
|
||||
|
||||
(define (tzid-from-/etc/TIMEZONE)
|
||||
(define /etc/TIMEZONE "/etc/TIMEZONE")
|
||||
|
||||
(tzid-from-var /etc/TIMEZONE "TZ"))
|
||||
|
||||
(define (tzid-from-/etc/sysconfig/clock)
|
||||
(define /etc/sysconfig/clock "/etc/sysconfig/clock")
|
||||
|
||||
(tzid-from-var /etc/sysconfig/clock "(?:TIMEZONE|ZONE)"))
|
||||
|
||||
(define (tzid-from-/etc/default/init)
|
||||
(define /etc/default/init "/etc/default/init")
|
||||
|
||||
(tzid-from-var /etc/default/init "TZ"))
|
||||
|
||||
(define (tzid-from-var file var)
|
||||
(define re (pregexp (string-append "^\\s*" var "\\s*=\\s*(\\S+)")))
|
||||
|
||||
(and (file-exists? file)
|
||||
(for*/last ([s (in-list (file->lines file))]
|
||||
[m (in-value (regexp-match re s))]
|
||||
#:when m)
|
||||
(cadr m))))
|
|
@ -1,81 +0,0 @@
|
|||
#lang racket/base
|
||||
|
||||
(require ffi/unsafe
|
||||
ffi/unsafe/define
|
||||
ffi/winapi)
|
||||
|
||||
(provide subresources)
|
||||
|
||||
(define _HKEY (_cpointer/null 'HKEY))
|
||||
(define _LONG _long)
|
||||
(define _DWORD _int32)
|
||||
(define _REGSAM _DWORD)
|
||||
(define _BOOL (make-ctype _int (lambda (v) (if v 1 0)) (lambda (v) (not (zero? v)))))
|
||||
|
||||
(define KEY_QUERY_VALUE #x1)
|
||||
(define KEY_ENUMERATE_SUB_KEYS #x8)
|
||||
|
||||
(define ERROR_SUCCESS 0)
|
||||
|
||||
(define (const-hkey v)
|
||||
(cast (bitwise-ior v (arithmetic-shift -1 32)) _intptr _HKEY))
|
||||
|
||||
(define HKEY_CLASSES_ROOT (const-hkey #x80000000))
|
||||
(define HKEY_CURRENT_USER (const-hkey #x80000001))
|
||||
(define HKEY_LOCAL_MACHINE (const-hkey #x80000002))
|
||||
(define HKEY_USERS (const-hkey #x80000003))
|
||||
(define HKEY_CURRENT_CONFIG (const-hkey #x80000005))
|
||||
|
||||
(define advapi-dll (and (eq? (system-type) 'windows)
|
||||
(ffi-lib "Advapi32.dll")))
|
||||
|
||||
(define-ffi-definer define-advapi advapi-dll
|
||||
#:default-make-fail make-not-available)
|
||||
|
||||
(define-advapi RegOpenKeyExW
|
||||
(_fun #:abi winapi
|
||||
_HKEY _string/utf-16 _DWORD _REGSAM (hkey : (_ptr o _HKEY))
|
||||
-> (r : _LONG)
|
||||
-> (and (= r ERROR_SUCCESS) hkey)))
|
||||
|
||||
(define-advapi RegCloseKey (_fun #:abi winapi _HKEY -> _LONG))
|
||||
|
||||
(define-advapi RegEnumKeyExW
|
||||
(_fun #:abi winapi
|
||||
_HKEY
|
||||
_DWORD
|
||||
(name : (_bytes o 256))
|
||||
(name-len : (_ptr io _DWORD))
|
||||
(_pointer = #f)
|
||||
(_pointer = #f)
|
||||
(_pointer = #f)
|
||||
(_pointer = #f)
|
||||
-> (r : _LONG)
|
||||
-> (and (= r ERROR_SUCCESS)
|
||||
(let*-values
|
||||
([(cnv) (bytes-open-converter "platform-UTF-16" "platform-UTF-8")]
|
||||
[(bs n _) (bytes-convert cnv name 0 (* 2 name-len))]
|
||||
[(str) (bytes->string/utf-8 bs)])
|
||||
(bytes-close-converter cnv)
|
||||
str))))
|
||||
|
||||
(define (section->hkey section)
|
||||
(case section
|
||||
[("HKEY_CLASSES_ROOT") HKEY_CLASSES_ROOT]
|
||||
[("HKEY_CURRENT_CONFIG") HKEY_CURRENT_CONFIG]
|
||||
[("HKEY_CURRENT_USER") HKEY_CURRENT_USER]
|
||||
[("HKEY_LOCAL_MACHINE") HKEY_LOCAL_MACHINE]
|
||||
[("HKEY_USERS") HKEY_USERS]
|
||||
[else (error "bad section")]))
|
||||
|
||||
|
||||
(define (subresources section entry)
|
||||
(define hkey (section->hkey section))
|
||||
(define sub-hkey (RegOpenKeyExW hkey entry 0 KEY_ENUMERATE_SUB_KEYS))
|
||||
(define result
|
||||
(for*/list ([i (in-naturals)]
|
||||
[key (in-value (RegEnumKeyExW sub-hkey i 256))]
|
||||
#:break (not key))
|
||||
key))
|
||||
(RegCloseKey sub-hkey)
|
||||
result)
|
|
@ -1,49 +0,0 @@
|
|||
#lang racket/base
|
||||
|
||||
(require file/resource
|
||||
"../../../cldr/core.rkt"
|
||||
"env.rkt"
|
||||
"windows-registry.rkt")
|
||||
|
||||
(provide detect-tzid/windows)
|
||||
|
||||
(define (detect-tzid/windows)
|
||||
(or (tzid-from-env)
|
||||
(tzid-from-registry/vista)
|
||||
(tzid-from-registry/nt)
|
||||
(tzid-from-registry/95)))
|
||||
|
||||
(define (tzid-from-registry/vista)
|
||||
(windows->tzid
|
||||
(get-resource KEY (string-append TZINFO-KEY "\\TimeZoneKeyName"))))
|
||||
|
||||
(define (tzid-from-registry/nt)
|
||||
(windows->tzid
|
||||
(tzid-from-registry-list "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones")))
|
||||
|
||||
(define (tzid-from-registry/95)
|
||||
(windows->tzid
|
||||
(tzid-from-registry-list "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Time Zones")))
|
||||
|
||||
(define (windows->tzid tz)
|
||||
(and tz
|
||||
(for*/first ([mz (in-list (windows-zones))]
|
||||
[win (in-value (cldr-ref mz '(mapZone _other)))]
|
||||
#:when (equal? tz win))
|
||||
(cldr-ref mz '(mapZone _type)))))
|
||||
|
||||
(define (tzid-from-registry-list prefix)
|
||||
(define standard (standard-name))
|
||||
(define tzs (subresources KEY prefix))
|
||||
|
||||
(for*/first ([tz (in-list tzs)]
|
||||
[std (in-value (get-resource KEY (format "~a\\~a\\Std" prefix tz)))]
|
||||
#:when (equal? standard std))
|
||||
tz))
|
||||
|
||||
(define (standard-name)
|
||||
(get-resource KEY (string-append TZINFO-KEY "\\StandardName")))
|
||||
|
||||
|
||||
(define KEY "HKEY_LOCAL_MACHINE")
|
||||
(define TZINFO-KEY "SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation")
|
|
@ -1,47 +0,0 @@
|
|||
#lang racket/base
|
||||
|
||||
(provide (all-defined-out))
|
||||
|
||||
(struct tzoffset
|
||||
(utc-seconds
|
||||
dst?
|
||||
abbreviation)
|
||||
#:transparent)
|
||||
|
||||
(struct tzgap
|
||||
(starts-at
|
||||
offset-before
|
||||
offset-after)
|
||||
#:transparent)
|
||||
|
||||
(struct tzoverlap
|
||||
(offset-before
|
||||
offset-after)
|
||||
#:transparent)
|
||||
|
||||
(struct interval
|
||||
(from
|
||||
to
|
||||
offset)
|
||||
#:transparent)
|
||||
|
||||
(struct zone
|
||||
(id
|
||||
intervals
|
||||
offsets)
|
||||
#:transparent)
|
||||
|
||||
(struct tabzone
|
||||
(id
|
||||
country-codes
|
||||
coordinates
|
||||
comments)
|
||||
#:transparent)
|
||||
|
||||
(struct coordinates
|
||||
(latitude
|
||||
longitude)
|
||||
#:transparent)
|
||||
|
||||
(struct exn:fail:tzinfo exn:fail () #:transparent)
|
||||
(struct exn:fail:tzinfo:zone-not-found exn:fail:tzinfo () #:transparent)
|
|
@ -1,59 +0,0 @@
|
|||
#lang racket/base
|
||||
|
||||
(require racket/contract/base
|
||||
racket/match
|
||||
racket/string)
|
||||
(require "structs.rkt")
|
||||
|
||||
(provide/contract
|
||||
[parse-tabfile (-> path-string? (hash/c string? tabzone?))])
|
||||
|
||||
(define (parse-tabfile dir)
|
||||
(define path (tabfile-path dir))
|
||||
(call-with-input-file* path read-tabfile))
|
||||
|
||||
(define (read-tabfile in)
|
||||
(define re #px"^([^#\t]+)[\t]([^\t]+)[\t]([^\t]+)(?:[\t](.*))?")
|
||||
(for*/hash ([line (in-lines in)]
|
||||
[parts (in-value (regexp-match re line))]
|
||||
#:when parts)
|
||||
(match parts
|
||||
[(list _ codes coords tzid comments)
|
||||
(values tzid
|
||||
(tabzone (string->immutable-string tzid)
|
||||
(map string->immutable-string
|
||||
(string-split codes ","))
|
||||
(parse-coordinates coords)
|
||||
(and comments
|
||||
(string->immutable-string comments))))])))
|
||||
|
||||
(define (parse-coordinates str)
|
||||
(match str
|
||||
[(regexp #px"([-+])(.{2,3})(.{2})(.{2})?([-+])(.{2,3})(.{2})(.{2})?"
|
||||
(list _
|
||||
lat-sgn lat-deg lat-min lat-sec
|
||||
lon-sgn lon-deg lon-min lon-sec))
|
||||
(coordinates
|
||||
(->degrees lat-sgn lat-deg lat-min lat-sec)
|
||||
(->degrees lon-sgn lon-deg lon-min lon-sec))]))
|
||||
|
||||
(define (->degrees sgn d m s)
|
||||
(define absolute
|
||||
(+ (string->number d)
|
||||
(/ (string->number m) 60)
|
||||
(/ (or (and s (string->number s)) 0) 3600)))
|
||||
|
||||
(case sgn
|
||||
[("+") absolute]
|
||||
[else (- absolute)]))
|
||||
|
||||
(define (tabfile-path dir)
|
||||
(define paths
|
||||
'(("zone1970.tab")
|
||||
("zone.tab")
|
||||
("tab" "zone_sun.tab")))
|
||||
|
||||
(for*/first ([suffix (in-list paths)]
|
||||
[p (in-value (apply build-path dir suffix))]
|
||||
#:when (file-exists? p))
|
||||
p))
|
|
@ -1,132 +0,0 @@
|
|||
#lang racket/base
|
||||
|
||||
(require racket/contract/base
|
||||
racket/match
|
||||
racket/vector)
|
||||
(require "structs.rkt")
|
||||
|
||||
(provide/contract
|
||||
[parse-tzfile (-> path-string? string? (vector/c (vectorof interval?) (vectorof tzoffset?)))])
|
||||
|
||||
(struct header
|
||||
(magic version gmtcnt stdcnt leapcnt txcnt offcnt chrcnt)
|
||||
#:transparent)
|
||||
|
||||
(struct offset
|
||||
(utc-seconds
|
||||
dst?
|
||||
abbreviation-index)
|
||||
#:transparent)
|
||||
|
||||
(define (parse-tzfile dir tzid)
|
||||
(define path (build-path dir tzid))
|
||||
(unless (file-exists? path)
|
||||
(raise (exn:fail:tzinfo:zone-not-found
|
||||
(format "Cannot find zoneinfo file for [~a]" tzid)
|
||||
(current-continuation-marks))))
|
||||
(call-with-input-file* path parse-tzfile-contents))
|
||||
|
||||
(define (skip-32bit-section in header32)
|
||||
(match header32
|
||||
[(header _ _ g s l t o c)
|
||||
(skip-bytes in (+ (* 5 t) (* 6 o) (* 8 l) g s c))]))
|
||||
|
||||
(define (parse-transition-times in header word-size)
|
||||
(for/list ([i (in-range (header-txcnt header))])
|
||||
(integer-bytes->integer (read-bytes word-size in) #t #t)))
|
||||
|
||||
(define (parse-transition-offsets in header)
|
||||
(for/list ([i (in-range (header-txcnt header))])
|
||||
(read-byte in)))
|
||||
|
||||
(define (parse-offsets in header)
|
||||
(for/vector ([i (in-range (header-offcnt header))])
|
||||
(offset (integer-bytes->integer (read-bytes 4 in) #t #t)
|
||||
(= (read-byte in) 1)
|
||||
(read-byte in))))
|
||||
|
||||
(define (build-tzoffsets offsets abbreviation-bytes)
|
||||
(vector-map (λ (o)
|
||||
(match o
|
||||
[(offset t d? i)
|
||||
(tzoffset t
|
||||
d?
|
||||
(string->immutable-string
|
||||
(bytes->string/utf-8
|
||||
(car (regexp-match #px#"[^\0]+" abbreviation-bytes i)))))]))
|
||||
offsets))
|
||||
|
||||
(define (build-intervals txtimes offset-indices tzoffsets)
|
||||
(define base-intervals
|
||||
(reverse
|
||||
(let loop ([res '()] [xs txtimes] [ys offset-indices])
|
||||
(match* (xs ys)
|
||||
[('() '())
|
||||
res]
|
||||
[((list t) (list i))
|
||||
(cons (interval t +inf.0 (vector-ref tzoffsets i))
|
||||
res)]
|
||||
[((list-rest t1 t2 xs) (cons i ys))
|
||||
(loop
|
||||
(cons (interval t1 t2 (vector-ref tzoffsets i))
|
||||
res)
|
||||
(cons t2 xs)
|
||||
ys)]))))
|
||||
|
||||
(match base-intervals
|
||||
['()
|
||||
;; no intervals: create a single, infinite interval
|
||||
(list (interval -inf.0 +inf.0 (vector-ref tzoffsets 0)))]
|
||||
[(cons (interval _ t (and off (tzoffset _ #f _))) xs)
|
||||
;; our first interval is in standard time: extend it to -inf.0
|
||||
(cons (interval -inf.0 t off) xs)]
|
||||
[(cons (and x (interval t _ _)) xs)
|
||||
;; our first interval is in DST: prepend a starting interval
|
||||
(list* (interval -inf.0 t (first-standard-offset base-intervals))
|
||||
x
|
||||
xs)]))
|
||||
|
||||
(define (first-standard-offset intervals)
|
||||
(for*/first ([int (in-list intervals)]
|
||||
[off (in-value (interval-offset int))]
|
||||
#:unless (tzoffset-dst? off))
|
||||
off))
|
||||
|
||||
|
||||
|
||||
(define (parse-tzfile-contents in)
|
||||
(define header32 (parse-header in))
|
||||
(match-define (vector header word-size)
|
||||
(match (header-version header32)
|
||||
[(or #"2" #"3")
|
||||
(skip-32bit-section in header32)
|
||||
(vector (parse-header in) 8)]
|
||||
[_
|
||||
(vector header32 4)]))
|
||||
|
||||
(define transition-times (parse-transition-times in header word-size))
|
||||
(define transition-offsets (parse-transition-offsets in header))
|
||||
(define offsets (parse-offsets in header))
|
||||
(define abbreviation-bytes (read-bytes (header-chrcnt header) in))
|
||||
(define tzoffsets (build-tzoffsets offsets abbreviation-bytes))
|
||||
(define intervals (build-intervals transition-times transition-offsets tzoffsets))
|
||||
|
||||
|
||||
(vector (list->vector intervals)
|
||||
tzoffsets))
|
||||
|
||||
|
||||
(define (parse-header in)
|
||||
(define bs (read-bytes 44 in))
|
||||
(header (subbytes bs 0 4)
|
||||
(subbytes bs 4 5)
|
||||
(integer-bytes->integer (subbytes bs 20 24) #f #t)
|
||||
(integer-bytes->integer (subbytes bs 24 28) #f #t)
|
||||
(integer-bytes->integer (subbytes bs 28 32) #f #t)
|
||||
(integer-bytes->integer (subbytes bs 32 36) #f #t)
|
||||
(integer-bytes->integer (subbytes bs 36 40) #f #t)
|
||||
(integer-bytes->integer (subbytes bs 40 44) #f #t)))
|
||||
|
||||
|
||||
(define (skip-bytes in n)
|
||||
(file-position in (+ n (file-position in))))
|
|
@ -1,65 +0,0 @@
|
|||
#lang racket/base
|
||||
|
||||
(require racket/contract/base
|
||||
racket/match)
|
||||
(require "structs.rkt")
|
||||
|
||||
(provide/contract
|
||||
[find-utc-offset (-> (vectorof interval?) real? tzoffset?)]
|
||||
[find-local-offset (-> (vectorof interval?) real? (or/c tzoffset? tzgap? tzoverlap?))])
|
||||
|
||||
(define (find-utc-offset intervals seconds)
|
||||
(match (binary-search intervals seconds (λ (x) 0) 0 (vector-length intervals) #f #f)
|
||||
[`#s(present ,idx)
|
||||
(interval-offset (vector-ref intervals idx))]))
|
||||
|
||||
(define (find-local-offset intervals seconds)
|
||||
(define (in-interval? n)
|
||||
(and (>= n 0)
|
||||
(< n (vector-length intervals))
|
||||
(eq? '= (interval-cmp (vector-ref intervals n) seconds tzoffset-utc-seconds))))
|
||||
|
||||
(define (offset-at n)
|
||||
(interval-offset (vector-ref intervals n)))
|
||||
|
||||
(match (binary-search intervals seconds tzoffset-utc-seconds 0 (vector-length intervals) #f #f)
|
||||
[`#s(present ,idx)
|
||||
;; could be an overlap
|
||||
(cond [(in-interval? (sub1 idx))
|
||||
(tzoverlap (offset-at (sub1 idx))
|
||||
(offset-at idx))]
|
||||
[(in-interval? (add1 idx))
|
||||
(tzoverlap (offset-at idx)
|
||||
(offset-at (add1 idx)))]
|
||||
[else
|
||||
(offset-at idx)])]
|
||||
[`#s(absent ,idx)
|
||||
;; gap
|
||||
(match (vector-ref intervals idx)
|
||||
[(interval t _ o)
|
||||
(tzgap t (offset-at (sub1 idx)) o)])]))
|
||||
|
||||
|
||||
(define (binary-search intervals t offset->delta start end last best)
|
||||
(define i (quotient (+ end start) 2))
|
||||
|
||||
(cond [(or (= start end)
|
||||
(eq? i last))
|
||||
`#s(absent ,best)]
|
||||
[else
|
||||
(case (interval-cmp (vector-ref intervals i) t offset->delta)
|
||||
[(=) `#s(present ,i)]
|
||||
[(<) (binary-search intervals t offset->delta start i i i)]
|
||||
[(>) (binary-search intervals t offset->delta i end i (add1 i))])]))
|
||||
|
||||
(define (interval-cmp int t offset->delta)
|
||||
(match int
|
||||
[(interval t1 t2 off)
|
||||
(define delta (offset->delta off))
|
||||
(define lo (+ t1 delta))
|
||||
(define hi (+ t2 delta))
|
||||
|
||||
(cond [(< t lo) '<]
|
||||
[(>= t hi) '>]
|
||||
[else '=])]))
|
||||
|
|
@ -1,127 +0,0 @@
|
|||
#lang racket/base
|
||||
|
||||
(require racket/contract/base
|
||||
racket/path
|
||||
racket/match
|
||||
racket/set
|
||||
racket/string)
|
||||
(require "generics.rkt"
|
||||
"structs.rkt"
|
||||
"os/unix.rkt"
|
||||
"os/windows.rkt"
|
||||
"tzfile-parser.rkt"
|
||||
"tabfile-parser.rkt"
|
||||
"zoneinfo-search.rkt")
|
||||
|
||||
(provide (struct-out zoneinfo)
|
||||
current-zoneinfo-search-path
|
||||
make-zoneinfo-source)
|
||||
|
||||
(define (zoneinfo-seconds->tzoffset/utc zi tzid s)
|
||||
(define zone (zoneinfo-zone zi tzid))
|
||||
(find-utc-offset (zone-intervals zone) s))
|
||||
|
||||
(define (zoneinfo-seconds->tzoffset/local zi tzid s)
|
||||
(define zone (zoneinfo-zone zi tzid))
|
||||
(find-local-offset (zone-intervals zone) s))
|
||||
|
||||
(struct zoneinfo
|
||||
(dir
|
||||
tzids
|
||||
zones
|
||||
tabzone-index)
|
||||
#:transparent
|
||||
#:methods gen:tzinfo-source
|
||||
[(define seconds->tzoffset/utc zoneinfo-seconds->tzoffset/utc)
|
||||
(define seconds->tzoffset/local zoneinfo-seconds->tzoffset/local)
|
||||
|
||||
(define (tzinfo->all-tzids zi)
|
||||
(sort (set->list (zoneinfo-tzids zi))
|
||||
string<?))
|
||||
|
||||
(define (tzinfo-has-tzid? zi tzid)
|
||||
(set-member? (zoneinfo-tzids zi) tzid))
|
||||
|
||||
(define (tzinfo-tzid->country-codes zi tzid)
|
||||
(define tab (hash-ref (zoneinfo-tabzone-index zi) tzid #f))
|
||||
(if tab (tabzone-country-codes tab) '()))
|
||||
|
||||
(define (tzinfo-country-code->tzids zi cc)
|
||||
(for/list ([tab (in-hash-values (zoneinfo-tabzone-index zi))]
|
||||
#:when (member cc (tabzone-country-codes tab)))
|
||||
(tabzone-id tab)))
|
||||
|
||||
(define (detect-system-tzid zi)
|
||||
(define candidate
|
||||
(case (system-type)
|
||||
[(unix macosx)
|
||||
(detect-tzid/unix (zoneinfo-dir zi)
|
||||
(find-zoneinfo-directory default-zoneinfo-search-path)
|
||||
(tzinfo->all-tzids zi))]
|
||||
[(windows)
|
||||
(detect-tzid/windows)]
|
||||
[else
|
||||
#f]))
|
||||
|
||||
(and (tzinfo-has-tzid? zi candidate)
|
||||
(string->immutable-string candidate)))])
|
||||
|
||||
|
||||
(define (make-zoneinfo-source)
|
||||
(define dir (find-zoneinfo-directory))
|
||||
(zoneinfo dir
|
||||
(read-tzids dir)
|
||||
(make-hash)
|
||||
(parse-tabfile dir)))
|
||||
|
||||
(define (zoneinfo-zone zinfo tzid)
|
||||
(hash-ref! (zoneinfo-zones zinfo)
|
||||
tzid
|
||||
(λ () (build-zone zinfo tzid))))
|
||||
|
||||
(define (build-zone zinfo tzid)
|
||||
(match (parse-tzfile (zoneinfo-dir zinfo) tzid)
|
||||
[(vector intervals offsets)
|
||||
(zone tzid intervals offsets)]))
|
||||
|
||||
(define default-zoneinfo-search-path
|
||||
(list "/usr/share/zoneinfo"
|
||||
"/usr/share/lib/zoneinfo"
|
||||
"/etc/zoneinfo"))
|
||||
|
||||
(define current-zoneinfo-search-path
|
||||
(make-parameter default-zoneinfo-search-path))
|
||||
|
||||
(define (find-zoneinfo-directory [path-list (current-zoneinfo-search-path)])
|
||||
(for/first ([path (in-list path-list)]
|
||||
#:when (valid-zoneinfo-directory? path))
|
||||
path))
|
||||
|
||||
(define (valid-zoneinfo-directory? path)
|
||||
(and (directory-exists? path)
|
||||
(ormap file-exists?
|
||||
(list (build-path path "zone1970.tab")
|
||||
(build-path path "zone.tab")
|
||||
(build-path path "tab" "zone_sun.tab")))))
|
||||
|
||||
(define (read-tzids dir)
|
||||
(define (use-path? p)
|
||||
(use-relative-path? (find-relative-path dir p)))
|
||||
|
||||
(define (use-relative-path? rel)
|
||||
(define rel-str (path->string rel))
|
||||
|
||||
(and (not (regexp-match #rx"\\." rel-str))
|
||||
(andmap (λ (f) (not (equal? rel-str f))) EXCLUDED-ZONEINFO-PATHS)))
|
||||
|
||||
(for*/set ([p (in-directory dir use-path?)]
|
||||
[r (in-value (find-relative-path dir p))]
|
||||
#:when (and (not (directory-exists? p))
|
||||
(use-relative-path? r)))
|
||||
(string->immutable-string
|
||||
(string-join
|
||||
(map path->string (explode-path r))
|
||||
"/"))))
|
||||
|
||||
(define EXCLUDED-ZONEINFO-PATHS
|
||||
'("+VERSION" "localtime" "posix" "posixrules" "right" "src" "Factory"))
|
|
@ -1,229 +0,0 @@
|
|||
#lang scribble/manual
|
||||
|
||||
@(require scribble/eval
|
||||
(for-label racket/base
|
||||
racket/contract
|
||||
tzinfo))
|
||||
|
||||
@(define the-eval (make-base-eval))
|
||||
@(the-eval '(require tzinfo))
|
||||
|
||||
@title{TZInfo}
|
||||
@author{@(author+email "Jon Zeppieri" "zeppieri@gmail.com")}
|
||||
|
||||
@defmodule[tzinfo]
|
||||
|
||||
@section{Introduction}
|
||||
|
||||
The @tt{tzinfo} library provides an interface for querying the IANA time zone database
|
||||
(also known as the Olson database).
|
||||
|
||||
UNIX systems usually come with a compiled version of the IANA database (typically in
|
||||
@tt{/usr/share/zoneinfo}). @tt{tzinfo} will use the system's database if available.
|
||||
However, if the @tt{tzdata} package is installed, that will be used instead. Since
|
||||
Windows systems do not come with a zoneinfo database, Windows users must install
|
||||
@tt{tzdata} to use @tt{tzinfo}.
|
||||
|
||||
@section{Querying the Database}
|
||||
|
||||
@defproc[(all-tzids) (listof string?)]{
|
||||
Returns a list containing all of the time zone IDs in the database.
|
||||
}
|
||||
|
||||
@defproc[(tzid-exists? [tzid string?]) boolean?]{
|
||||
Returns @racket[#t] if the given ID is in the database, @racket[#f] otherwise.
|
||||
|
||||
@examples[#:eval the-eval
|
||||
(tzid-exists? "Europe/London")
|
||||
(tzid-exists? "Fillory/Whitespire")
|
||||
]
|
||||
}
|
||||
|
||||
@defproc[(utc-seconds->tzoffset [tzid string?]
|
||||
[seconds real?])
|
||||
tzoffset?]{
|
||||
For a given time zone ID and number of seconds since the UNIX epoch (1970-01-01 00:00:00 UTC),
|
||||
returns a @racket[tzoffset?] describing the offset from UTC in effect at that moment of time
|
||||
in the given time zone. Raises @racket[exn:fail:tzinfo:zone-not-found] if the given time zone
|
||||
ID is not in the database.
|
||||
|
||||
@examples[#:eval the-eval
|
||||
(utc-seconds->tzoffset "America/New_York" 0)
|
||||
(utc-seconds->tzoffset "Fillory/Whitespire" 0)
|
||||
]
|
||||
}
|
||||
|
||||
@defproc[(local-seconds->tzoffset [tzid string?]
|
||||
[seconds real?])
|
||||
(or/c tzoffset? tzgap? tzoverlap?)]{
|
||||
For a given time zone ID and number of seconds since 1970-01-01 00:00:00
|
||||
@italic{in the given time zone}, returns one of:
|
||||
|
||||
@itemize[
|
||||
@item{
|
||||
a @tt{tzoffset} struct, describing the offset from UTC in effect at the given time in the given time zone;
|
||||
}
|
||||
@item{
|
||||
a @tt{tzgap} struct if the given local time falls into a gap between different offsets (as, for example,
|
||||
when an hour is skipped at the start of daylight saving time in most parts of the United States); or
|
||||
}
|
||||
@item{
|
||||
a @tt{tzoverlap} struct if the given local time falls in a period when two different offsets might be
|
||||
in effect (as, for example, at the end of daylight saving time, when an hour is repeated).
|
||||
}
|
||||
]
|
||||
|
||||
Raises @racket[exn:fail:tzinfo:zone-not-found] if the given time zone ID is not in the database.
|
||||
|
||||
@examples[#:eval the-eval
|
||||
(local-seconds->tzoffset "America/New_York" 1409606993)
|
||||
(local-seconds->tzoffset "America/New_York" 1394330400)
|
||||
(local-seconds->tzoffset "America/New_York" 1414890000)
|
||||
]
|
||||
}
|
||||
|
||||
@defproc[(tzid->country-codes [tzid string?]) (listof string?)]{
|
||||
Returns a list of ISO 3166 alpha-2 country codes in which the given time zone is used.
|
||||
|
||||
@examples[#:eval the-eval
|
||||
(tzid->country-codes "Europe/Moscow")
|
||||
(tzid->country-codes "Antarctica/Troll")
|
||||
(tzid->country-codes "Africa/Kinshasa")
|
||||
]
|
||||
}
|
||||
|
||||
@defproc[(country-code->tzids [cc string?]) (listof string?)]{
|
||||
Returns a list of time zone IDs that are used in the country identified by the given
|
||||
ISO 3166 alpha-2 country code.
|
||||
|
||||
@examples[#:eval the-eval
|
||||
(country-code->tzids "US")
|
||||
(country-code->tzids "IT")
|
||||
]
|
||||
}
|
||||
|
||||
@defproc[(system-tzid) (or/c string? #f)]{
|
||||
Returns the ID of the current system time zone, if it can be determined, @racket[#f] otherwise.
|
||||
}
|
||||
|
||||
@defstruct*[exn:fail:tzinfo:zone-not-found ()]{
|
||||
An exception that is raised by query functions when the given time zone ID does not
|
||||
exist in the tzinfo database.
|
||||
}
|
||||
|
||||
@section{Offsets, Gaps, and Overlaps}
|
||||
|
||||
@defstruct*[tzoffset ([utc-seconds exact-integer?]
|
||||
[dst? boolean?]
|
||||
[abbreviation string?])
|
||||
#:transparent]{
|
||||
A structure type representing a time zone-specific offset from UTC.
|
||||
@tt{utc-seconds} contains the different from UTC
|
||||
in seconds. @tt{dst?} is true just in case the offset represents an offset in effect during
|
||||
daylight saving time. @tt{abbreviation} is, e.g., "EST" for "Eastern Standard Time," "BST" for
|
||||
"British Summer Time," etc.
|
||||
}
|
||||
|
||||
@defstruct*[tzgap ([starts-at exact-integer?]
|
||||
[offset-before tzoffset?]
|
||||
[offset-after tzoffset?])
|
||||
#:transparent]{
|
||||
A structure type representing a time zone-specific gap between two offsets from UTC. Gaps occur
|
||||
at the start of daylight saving time.
|
||||
@tt{starts-at} is the start of the gap, represented as a number of seconds since the UNIX epoch.
|
||||
@tt{offset-before} is the @tt{tzoffset} in effect before the gap.
|
||||
@tt{offset-after} is the @tt{tzoffset} in effect after the gap.
|
||||
}
|
||||
|
||||
@defstruct*[tzoverlap ([offset-before tzoffset?]
|
||||
[offset-after tzoffset?])
|
||||
#:transparent]{
|
||||
A structure type representing a time-zone specific overlap of two different offsets. Overlaps
|
||||
occur at the end of daylight saving time.
|
||||
@tt{offset-before} is the earlier offset. E.g., when going from daylight saving time to standard time,
|
||||
@tt{offset-before} is the daylight saving time offset.
|
||||
@tt{offset-after} is the later offset.
|
||||
}
|
||||
|
||||
@section{Data Sources}
|
||||
|
||||
@tt{tzinfo} allows for a pluggable data sources. At present, the only supported source
|
||||
is based on @tt{zoneinfo} files, which are a compiled form of the IANA database, widely-
|
||||
used on UNIX systems.
|
||||
|
||||
@defparam[current-tzinfo-source tzinfo-source tzinfo-source? #:value #f]{
|
||||
A parameter containing the current @tt{tzinfo} data source.
|
||||
}
|
||||
|
||||
@defproc[(set-default-tzinfo-source-constructor! [ctor (-> tzinfo-source?)]) void?]{
|
||||
Sets the constructor function that will be applied to build the default tzinfo source.
|
||||
To use a custom source, you must call this function before using any of the querying functions.
|
||||
}
|
||||
|
||||
@section{Data Source Generics}
|
||||
|
||||
@defmodule[tzinfo/source]
|
||||
|
||||
@defthing[gen:tzinfo-source any/c]{
|
||||
A generic interface for defining custom tzinfo data sources. It defines the following
|
||||
methods:
|
||||
|
||||
@itemize[
|
||||
@item{@racket[tzinfo->all-tzids]}
|
||||
@item{@racket[tzinfo-has-tzid?]}
|
||||
@item{@racket[tzinfo-tzid->country-codes]}
|
||||
@item{@racket[tzinfo-country-code->tzids]}
|
||||
@item{@racket[seconds->tzoffset/utc]}
|
||||
@item{@racket[seconds->tzoffset/local]}
|
||||
@item{@racket[detect-system-tzid]}
|
||||
]
|
||||
}
|
||||
|
||||
@defproc[(tzinfo-source? [v any/c]) boolean?]{
|
||||
Returns @racket[#t] if @racket[v] is a tzinfo source, @racket[#f] otherwise.
|
||||
}
|
||||
|
||||
@defproc[(tzinfo->all-tzids [src tzinfo-source?]) (listof string?)]{
|
||||
Returns the full list of time zone IDs contained in the given tzinfo source.
|
||||
}
|
||||
|
||||
@defproc[(tzinfo-has-tzid? [src tzinfo-source?]
|
||||
[tzid string?])
|
||||
boolean?]{
|
||||
@racket[#t] if the tzinfo source contains the given time zone ID, @racket[#f] otherwise.
|
||||
}
|
||||
|
||||
@defproc[(tzinfo-tzid->country-codes [src tzinfo-source?]
|
||||
[tzid string?])
|
||||
(listof string?)]{
|
||||
Returns the list of ISO 3166 alpha-2 country codes in which the given time zone is used, accoring
|
||||
to the tzinfo source data.
|
||||
}
|
||||
|
||||
@defproc[(tzinfo-country-code->tzids [src tzinfo-source?]
|
||||
[cc string?])
|
||||
(listof string?)]{
|
||||
Returns the list of time zone IDs that are used in the given country (identified by an
|
||||
ISO 3166 alpha-2 country code), according to the tzinfo data source.
|
||||
}
|
||||
|
||||
@defproc[(seconds->tzoffset/utc [src tzinfo-source?]
|
||||
[tzid string?]
|
||||
[seconds real?])
|
||||
tzoffset?]{
|
||||
Returns the @tt{tzoffset} in use at the given UTC time in the given time zone, according to
|
||||
the tzinfo source.
|
||||
}
|
||||
|
||||
@defproc[(seconds->tzoffset/local [src tzinfo-source?]
|
||||
[tzid string?]
|
||||
[seconds real?])
|
||||
(or/c tzoffset? tzgap? tzoverlap?)]{
|
||||
Returns a @tt{tzoffset}, @tt{tzgap}, or @tt{tzoveralap}, depending on what offset is in effect
|
||||
at the given local time in the given time zone, according to the tzinfo source.
|
||||
}
|
||||
|
||||
@defproc[(detect-system-tzid) (or/c string? #f)]{
|
||||
Returns the time zone ID currently in use by the operating system, if it can be detected,
|
||||
@racket[#f] otherwise.
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
#lang racket/base
|
||||
|
||||
(require racket/contract/base
|
||||
"private/generics.rkt"
|
||||
"private/structs.rkt")
|
||||
|
||||
(provide/contract
|
||||
[tzinfo-source? (-> any/c boolean?)]
|
||||
[tzinfo->all-tzids (-> tzinfo-source? (listof string?))]
|
||||
[tzinfo-has-tzid? (-> tzinfo-source? string? boolean?)]
|
||||
[tzinfo-tzid->country-codes (-> tzinfo-source? string? (listof string?))]
|
||||
[tzinfo-country-code->tzids (-> tzinfo-source? string? (listof string?))]
|
||||
[seconds->tzoffset/utc (-> tzinfo-source? string? real? tzoffset?)]
|
||||
[seconds->tzoffset/local (-> tzinfo-source? string? real? (or/c tzoffset? tzgap? tzoverlap?))]
|
||||
[detect-system-tzid (-> tzinfo-source? (or/c string? #f))])
|
||||
|
||||
(provide gen:tzinfo-source)
|
|
@ -1 +0,0 @@
|
|||
2014c
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,275 +0,0 @@
|
|||
# ISO 3166 alpha-2 country codes
|
||||
#
|
||||
# This file is in the public domain, so clarified as of
|
||||
# 2009-05-17 by Arthur David Olson.
|
||||
#
|
||||
# From Paul Eggert (2013-05-27):
|
||||
#
|
||||
# This file contains a table with the following columns:
|
||||
# 1. ISO 3166-1 alpha-2 country code, current as of
|
||||
# ISO 3166-1 Newsletter VI-15 (2013-05-10). See: Updates on ISO 3166
|
||||
# http://www.iso.org/iso/home/standards/country_codes/updates_on_iso_3166.htm
|
||||
# 2. The usual English name for the coded region,
|
||||
# chosen so that alphabetic sorting of subsets produces helpful lists.
|
||||
# This is not the same as the English name in the ISO 3166 tables.
|
||||
#
|
||||
# Columns are separated by a single tab.
|
||||
# The table is sorted by country code.
|
||||
#
|
||||
# Lines beginning with `#' are comments.
|
||||
#
|
||||
# This table is intended as an aid for users, to help them select time
|
||||
# zone data appropriate for their practical needs. It is not intended
|
||||
# to take or endorse any position on legal or territorial claims.
|
||||
#
|
||||
#country-
|
||||
#code name of country, territory, area, or subdivision
|
||||
AD Andorra
|
||||
AE United Arab Emirates
|
||||
AF Afghanistan
|
||||
AG Antigua & Barbuda
|
||||
AI Anguilla
|
||||
AL Albania
|
||||
AM Armenia
|
||||
AO Angola
|
||||
AQ Antarctica
|
||||
AR Argentina
|
||||
AS Samoa (American)
|
||||
AT Austria
|
||||
AU Australia
|
||||
AW Aruba
|
||||
AX Aaland Islands
|
||||
AZ Azerbaijan
|
||||
BA Bosnia & Herzegovina
|
||||
BB Barbados
|
||||
BD Bangladesh
|
||||
BE Belgium
|
||||
BF Burkina Faso
|
||||
BG Bulgaria
|
||||
BH Bahrain
|
||||
BI Burundi
|
||||
BJ Benin
|
||||
BL St Barthelemy
|
||||
BM Bermuda
|
||||
BN Brunei
|
||||
BO Bolivia
|
||||
BQ Caribbean Netherlands
|
||||
BR Brazil
|
||||
BS Bahamas
|
||||
BT Bhutan
|
||||
BV Bouvet Island
|
||||
BW Botswana
|
||||
BY Belarus
|
||||
BZ Belize
|
||||
CA Canada
|
||||
CC Cocos (Keeling) Islands
|
||||
CD Congo (Dem. Rep.)
|
||||
CF Central African Rep.
|
||||
CG Congo (Rep.)
|
||||
CH Switzerland
|
||||
CI Cote d'Ivoire
|
||||
CK Cook Islands
|
||||
CL Chile
|
||||
CM Cameroon
|
||||
CN China
|
||||
CO Colombia
|
||||
CR Costa Rica
|
||||
CU Cuba
|
||||
CV Cape Verde
|
||||
CW Curacao
|
||||
CX Christmas Island
|
||||
CY Cyprus
|
||||
CZ Czech Republic
|
||||
DE Germany
|
||||
DJ Djibouti
|
||||
DK Denmark
|
||||
DM Dominica
|
||||
DO Dominican Republic
|
||||
DZ Algeria
|
||||
EC Ecuador
|
||||
EE Estonia
|
||||
EG Egypt
|
||||
EH Western Sahara
|
||||
ER Eritrea
|
||||
ES Spain
|
||||
ET Ethiopia
|
||||
FI Finland
|
||||
FJ Fiji
|
||||
FK Falkland Islands
|
||||
FM Micronesia
|
||||
FO Faroe Islands
|
||||
FR France
|
||||
GA Gabon
|
||||
GB Britain (UK)
|
||||
GD Grenada
|
||||
GE Georgia
|
||||
GF French Guiana
|
||||
GG Guernsey
|
||||
GH Ghana
|
||||
GI Gibraltar
|
||||
GL Greenland
|
||||
GM Gambia
|
||||
GN Guinea
|
||||
GP Guadeloupe
|
||||
GQ Equatorial Guinea
|
||||
GR Greece
|
||||
GS South Georgia & the South Sandwich Islands
|
||||
GT Guatemala
|
||||
GU Guam
|
||||
GW Guinea-Bissau
|
||||
GY Guyana
|
||||
HK Hong Kong
|
||||
HM Heard Island & McDonald Islands
|
||||
HN Honduras
|
||||
HR Croatia
|
||||
HT Haiti
|
||||
HU Hungary
|
||||
ID Indonesia
|
||||
IE Ireland
|
||||
IL Israel
|
||||
IM Isle of Man
|
||||
IN India
|
||||
IO British Indian Ocean Territory
|
||||
IQ Iraq
|
||||
IR Iran
|
||||
IS Iceland
|
||||
IT Italy
|
||||
JE Jersey
|
||||
JM Jamaica
|
||||
JO Jordan
|
||||
JP Japan
|
||||
KE Kenya
|
||||
KG Kyrgyzstan
|
||||
KH Cambodia
|
||||
KI Kiribati
|
||||
KM Comoros
|
||||
KN St Kitts & Nevis
|
||||
KP Korea (North)
|
||||
KR Korea (South)
|
||||
KW Kuwait
|
||||
KY Cayman Islands
|
||||
KZ Kazakhstan
|
||||
LA Laos
|
||||
LB Lebanon
|
||||
LC St Lucia
|
||||
LI Liechtenstein
|
||||
LK Sri Lanka
|
||||
LR Liberia
|
||||
LS Lesotho
|
||||
LT Lithuania
|
||||
LU Luxembourg
|
||||
LV Latvia
|
||||
LY Libya
|
||||
MA Morocco
|
||||
MC Monaco
|
||||
MD Moldova
|
||||
ME Montenegro
|
||||
MF St Martin (French part)
|
||||
MG Madagascar
|
||||
MH Marshall Islands
|
||||
MK Macedonia
|
||||
ML Mali
|
||||
MM Myanmar (Burma)
|
||||
MN Mongolia
|
||||
MO Macau
|
||||
MP Northern Mariana Islands
|
||||
MQ Martinique
|
||||
MR Mauritania
|
||||
MS Montserrat
|
||||
MT Malta
|
||||
MU Mauritius
|
||||
MV Maldives
|
||||
MW Malawi
|
||||
MX Mexico
|
||||
MY Malaysia
|
||||
MZ Mozambique
|
||||
NA Namibia
|
||||
NC New Caledonia
|
||||
NE Niger
|
||||
NF Norfolk Island
|
||||
NG Nigeria
|
||||
NI Nicaragua
|
||||
NL Netherlands
|
||||
NO Norway
|
||||
NP Nepal
|
||||
NR Nauru
|
||||
NU Niue
|
||||
NZ New Zealand
|
||||
OM Oman
|
||||
PA Panama
|
||||
PE Peru
|
||||
PF French Polynesia
|
||||
PG Papua New Guinea
|
||||
PH Philippines
|
||||
PK Pakistan
|
||||
PL Poland
|
||||
PM St Pierre & Miquelon
|
||||
PN Pitcairn
|
||||
PR Puerto Rico
|
||||
PS Palestine
|
||||
PT Portugal
|
||||
PW Palau
|
||||
PY Paraguay
|
||||
QA Qatar
|
||||
RE Reunion
|
||||
RO Romania
|
||||
RS Serbia
|
||||
RU Russia
|
||||
RW Rwanda
|
||||
SA Saudi Arabia
|
||||
SB Solomon Islands
|
||||
SC Seychelles
|
||||
SD Sudan
|
||||
SE Sweden
|
||||
SG Singapore
|
||||
SH St Helena
|
||||
SI Slovenia
|
||||
SJ Svalbard & Jan Mayen
|
||||
SK Slovakia
|
||||
SL Sierra Leone
|
||||
SM San Marino
|
||||
SN Senegal
|
||||
SO Somalia
|
||||
SR Suriname
|
||||
SS South Sudan
|
||||
ST Sao Tome & Principe
|
||||
SV El Salvador
|
||||
SX St Maarten (Dutch part)
|
||||
SY Syria
|
||||
SZ Swaziland
|
||||
TC Turks & Caicos Is
|
||||
TD Chad
|
||||
TF French Southern & Antarctic Lands
|
||||
TG Togo
|
||||
TH Thailand
|
||||
TJ Tajikistan
|
||||
TK Tokelau
|
||||
TL East Timor
|
||||
TM Turkmenistan
|
||||
TN Tunisia
|
||||
TO Tonga
|
||||
TR Turkey
|
||||
TT Trinidad & Tobago
|
||||
TV Tuvalu
|
||||
TW Taiwan
|
||||
TZ Tanzania
|
||||
UA Ukraine
|
||||
UG Uganda
|
||||
UM US minor outlying islands
|
||||
US United States
|
||||
UY Uruguay
|
||||
UZ Uzbekistan
|
||||
VA Vatican City
|
||||
VC St Vincent
|
||||
VE Venezuela
|
||||
VG Virgin Islands (UK)
|
||||
VI Virgin Islands (US)
|
||||
VN Vietnam
|
||||
VU Vanuatu
|
||||
WF Wallis & Futuna
|
||||
WS Samoa (western)
|
||||
YE Yemen
|
||||
YT Mayotte
|
||||
ZA South Africa
|
||||
ZM Zambia
|
||||
ZW Zimbabwe
|
Binary file not shown.
|
@ -1,452 +0,0 @@
|
|||
# TZ zone descriptions
|
||||
#
|
||||
# This file is in the public domain, so clarified as of
|
||||
# 2009-05-17 by Arthur David Olson.
|
||||
#
|
||||
# From Paul Eggert (2013-08-14):
|
||||
#
|
||||
# This file contains a table where each row stands for an area that is
|
||||
# the intersection of a region identified by a country code and of a
|
||||
# zone where civil clocks have agreed since 1970. The columns of the
|
||||
# table are as follows:
|
||||
#
|
||||
# 1. ISO 3166 2-character country code. See the file 'iso3166.tab'.
|
||||
# 2. Latitude and longitude of the area's principal location
|
||||
# in ISO 6709 sign-degrees-minutes-seconds format,
|
||||
# either +-DDMM+-DDDMM or +-DDMMSS+-DDDMMSS,
|
||||
# first latitude (+ is north), then longitude (+ is east).
|
||||
# 3. Zone name used in value of TZ environment variable.
|
||||
# Please see the 'Theory' file for how zone names are chosen.
|
||||
# If multiple zones overlap a country, each has a row in the
|
||||
# table, with column 1 being duplicated.
|
||||
# 4. Comments; present if and only if the country has multiple rows.
|
||||
#
|
||||
# Columns are separated by a single tab.
|
||||
# The table is sorted first by country, then an order within the country that
|
||||
# (1) makes some geographical sense, and
|
||||
# (2) puts the most populous areas first, where that does not contradict (1).
|
||||
#
|
||||
# Lines beginning with '#' are comments.
|
||||
#
|
||||
# This table is intended as an aid for users, to help them select time
|
||||
# zone data appropriate for their practical needs. It is not intended
|
||||
# to take or endorse any position on legal or territorial claims.
|
||||
#
|
||||
#country-
|
||||
#code coordinates TZ comments
|
||||
AD +4230+00131 Europe/Andorra
|
||||
AE +2518+05518 Asia/Dubai
|
||||
AF +3431+06912 Asia/Kabul
|
||||
AG +1703-06148 America/Antigua
|
||||
AI +1812-06304 America/Anguilla
|
||||
AL +4120+01950 Europe/Tirane
|
||||
AM +4011+04430 Asia/Yerevan
|
||||
AO -0848+01314 Africa/Luanda
|
||||
AQ -7750+16636 Antarctica/McMurdo McMurdo, South Pole, Scott (New Zealand time)
|
||||
AQ -6734-06808 Antarctica/Rothera Rothera Station, Adelaide Island
|
||||
AQ -6448-06406 Antarctica/Palmer Palmer Station, Anvers Island
|
||||
AQ -6736+06253 Antarctica/Mawson Mawson Station, Holme Bay
|
||||
AQ -6835+07758 Antarctica/Davis Davis Station, Vestfold Hills
|
||||
AQ -6617+11031 Antarctica/Casey Casey Station, Bailey Peninsula
|
||||
AQ -7824+10654 Antarctica/Vostok Vostok Station, Lake Vostok
|
||||
AQ -6640+14001 Antarctica/DumontDUrville Dumont-d'Urville Station, Terre Adelie
|
||||
AQ -690022+0393524 Antarctica/Syowa Syowa Station, E Ongul I
|
||||
AQ -720041+0023206 Antarctica/Troll Troll Station, Queen Maud Land
|
||||
AR -3436-05827 America/Argentina/Buenos_Aires Buenos Aires (BA, CF)
|
||||
AR -3124-06411 America/Argentina/Cordoba most locations (CB, CC, CN, ER, FM, MN, SE, SF)
|
||||
AR -2447-06525 America/Argentina/Salta (SA, LP, NQ, RN)
|
||||
AR -2411-06518 America/Argentina/Jujuy Jujuy (JY)
|
||||
AR -2649-06513 America/Argentina/Tucuman Tucuman (TM)
|
||||
AR -2828-06547 America/Argentina/Catamarca Catamarca (CT), Chubut (CH)
|
||||
AR -2926-06651 America/Argentina/La_Rioja La Rioja (LR)
|
||||
AR -3132-06831 America/Argentina/San_Juan San Juan (SJ)
|
||||
AR -3253-06849 America/Argentina/Mendoza Mendoza (MZ)
|
||||
AR -3319-06621 America/Argentina/San_Luis San Luis (SL)
|
||||
AR -5138-06913 America/Argentina/Rio_Gallegos Santa Cruz (SC)
|
||||
AR -5448-06818 America/Argentina/Ushuaia Tierra del Fuego (TF)
|
||||
AS -1416-17042 Pacific/Pago_Pago
|
||||
AT +4813+01620 Europe/Vienna
|
||||
AU -3133+15905 Australia/Lord_Howe Lord Howe Island
|
||||
AU -5430+15857 Antarctica/Macquarie Macquarie Island
|
||||
AU -4253+14719 Australia/Hobart Tasmania - most locations
|
||||
AU -3956+14352 Australia/Currie Tasmania - King Island
|
||||
AU -3749+14458 Australia/Melbourne Victoria
|
||||
AU -3352+15113 Australia/Sydney New South Wales - most locations
|
||||
AU -3157+14127 Australia/Broken_Hill New South Wales - Yancowinna
|
||||
AU -2728+15302 Australia/Brisbane Queensland - most locations
|
||||
AU -2016+14900 Australia/Lindeman Queensland - Holiday Islands
|
||||
AU -3455+13835 Australia/Adelaide South Australia
|
||||
AU -1228+13050 Australia/Darwin Northern Territory
|
||||
AU -3157+11551 Australia/Perth Western Australia - most locations
|
||||
AU -3143+12852 Australia/Eucla Western Australia - Eucla area
|
||||
AW +1230-06958 America/Aruba
|
||||
AX +6006+01957 Europe/Mariehamn
|
||||
AZ +4023+04951 Asia/Baku
|
||||
BA +4352+01825 Europe/Sarajevo
|
||||
BB +1306-05937 America/Barbados
|
||||
BD +2343+09025 Asia/Dhaka
|
||||
BE +5050+00420 Europe/Brussels
|
||||
BF +1222-00131 Africa/Ouagadougou
|
||||
BG +4241+02319 Europe/Sofia
|
||||
BH +2623+05035 Asia/Bahrain
|
||||
BI -0323+02922 Africa/Bujumbura
|
||||
BJ +0629+00237 Africa/Porto-Novo
|
||||
BL +1753-06251 America/St_Barthelemy
|
||||
BM +3217-06446 Atlantic/Bermuda
|
||||
BN +0456+11455 Asia/Brunei
|
||||
BO -1630-06809 America/La_Paz
|
||||
BQ +120903-0681636 America/Kralendijk
|
||||
BR -0351-03225 America/Noronha Atlantic islands
|
||||
BR -0127-04829 America/Belem Amapa, E Para
|
||||
BR -0343-03830 America/Fortaleza NE Brazil (MA, PI, CE, RN, PB)
|
||||
BR -0803-03454 America/Recife Pernambuco
|
||||
BR -0712-04812 America/Araguaina Tocantins
|
||||
BR -0940-03543 America/Maceio Alagoas, Sergipe
|
||||
BR -1259-03831 America/Bahia Bahia
|
||||
BR -2332-04637 America/Sao_Paulo S & SE Brazil (GO, DF, MG, ES, RJ, SP, PR, SC, RS)
|
||||
BR -2027-05437 America/Campo_Grande Mato Grosso do Sul
|
||||
BR -1535-05605 America/Cuiaba Mato Grosso
|
||||
BR -0226-05452 America/Santarem W Para
|
||||
BR -0846-06354 America/Porto_Velho Rondonia
|
||||
BR +0249-06040 America/Boa_Vista Roraima
|
||||
BR -0308-06001 America/Manaus E Amazonas
|
||||
BR -0640-06952 America/Eirunepe W Amazonas
|
||||
BR -0958-06748 America/Rio_Branco Acre
|
||||
BS +2505-07721 America/Nassau
|
||||
BT +2728+08939 Asia/Thimphu
|
||||
BW -2439+02555 Africa/Gaborone
|
||||
BY +5354+02734 Europe/Minsk
|
||||
BZ +1730-08812 America/Belize
|
||||
CA +4734-05243 America/St_Johns Newfoundland Time, including SE Labrador
|
||||
CA +4439-06336 America/Halifax Atlantic Time - Nova Scotia (most places), PEI
|
||||
CA +4612-05957 America/Glace_Bay Atlantic Time - Nova Scotia - places that did not observe DST 1966-1971
|
||||
CA +4606-06447 America/Moncton Atlantic Time - New Brunswick
|
||||
CA +5320-06025 America/Goose_Bay Atlantic Time - Labrador - most locations
|
||||
CA +5125-05707 America/Blanc-Sablon Atlantic Standard Time - Quebec - Lower North Shore
|
||||
CA +4339-07923 America/Toronto Eastern Time - Ontario & Quebec - most locations
|
||||
CA +4901-08816 America/Nipigon Eastern Time - Ontario & Quebec - places that did not observe DST 1967-1973
|
||||
CA +4823-08915 America/Thunder_Bay Eastern Time - Thunder Bay, Ontario
|
||||
CA +6344-06828 America/Iqaluit Eastern Time - east Nunavut - most locations
|
||||
CA +6608-06544 America/Pangnirtung Eastern Time - Pangnirtung, Nunavut
|
||||
CA +744144-0944945 America/Resolute Central Standard Time - Resolute, Nunavut
|
||||
CA +484531-0913718 America/Atikokan Eastern Standard Time - Atikokan, Ontario and Southampton I, Nunavut
|
||||
CA +624900-0920459 America/Rankin_Inlet Central Time - central Nunavut
|
||||
CA +4953-09709 America/Winnipeg Central Time - Manitoba & west Ontario
|
||||
CA +4843-09434 America/Rainy_River Central Time - Rainy River & Fort Frances, Ontario
|
||||
CA +5024-10439 America/Regina Central Standard Time - Saskatchewan - most locations
|
||||
CA +5017-10750 America/Swift_Current Central Standard Time - Saskatchewan - midwest
|
||||
CA +5333-11328 America/Edmonton Mountain Time - Alberta, east British Columbia & west Saskatchewan
|
||||
CA +690650-1050310 America/Cambridge_Bay Mountain Time - west Nunavut
|
||||
CA +6227-11421 America/Yellowknife Mountain Time - central Northwest Territories
|
||||
CA +682059-1334300 America/Inuvik Mountain Time - west Northwest Territories
|
||||
CA +4906-11631 America/Creston Mountain Standard Time - Creston, British Columbia
|
||||
CA +5946-12014 America/Dawson_Creek Mountain Standard Time - Dawson Creek & Fort Saint John, British Columbia
|
||||
CA +4916-12307 America/Vancouver Pacific Time - west British Columbia
|
||||
CA +6043-13503 America/Whitehorse Pacific Time - south Yukon
|
||||
CA +6404-13925 America/Dawson Pacific Time - north Yukon
|
||||
CC -1210+09655 Indian/Cocos
|
||||
CD -0418+01518 Africa/Kinshasa west Dem. Rep. of Congo
|
||||
CD -1140+02728 Africa/Lubumbashi east Dem. Rep. of Congo
|
||||
CF +0422+01835 Africa/Bangui
|
||||
CG -0416+01517 Africa/Brazzaville
|
||||
CH +4723+00832 Europe/Zurich
|
||||
CI +0519-00402 Africa/Abidjan
|
||||
CK -2114-15946 Pacific/Rarotonga
|
||||
CL -3327-07040 America/Santiago most locations
|
||||
CL -2709-10926 Pacific/Easter Easter Island & Sala y Gomez
|
||||
CM +0403+00942 Africa/Douala
|
||||
CN +3114+12128 Asia/Shanghai east China - Beijing, Guangdong, Shanghai, etc.
|
||||
CN +4545+12641 Asia/Harbin Heilongjiang (except Mohe), Jilin
|
||||
CN +2934+10635 Asia/Chongqing central China - Sichuan, Yunnan, Guangxi, Shaanxi, Guizhou, etc.
|
||||
CN +4348+08735 Asia/Urumqi most of Tibet & Xinjiang
|
||||
CN +3929+07559 Asia/Kashgar west Tibet & Xinjiang
|
||||
CO +0436-07405 America/Bogota
|
||||
CR +0956-08405 America/Costa_Rica
|
||||
CU +2308-08222 America/Havana
|
||||
CV +1455-02331 Atlantic/Cape_Verde
|
||||
CW +1211-06900 America/Curacao
|
||||
CX -1025+10543 Indian/Christmas
|
||||
CY +3510+03322 Asia/Nicosia
|
||||
CZ +5005+01426 Europe/Prague
|
||||
DE +5230+01322 Europe/Berlin most locations
|
||||
DE +4742+00841 Europe/Busingen Busingen
|
||||
DJ +1136+04309 Africa/Djibouti
|
||||
DK +5540+01235 Europe/Copenhagen
|
||||
DM +1518-06124 America/Dominica
|
||||
DO +1828-06954 America/Santo_Domingo
|
||||
DZ +3647+00303 Africa/Algiers
|
||||
EC -0210-07950 America/Guayaquil mainland
|
||||
EC -0054-08936 Pacific/Galapagos Galapagos Islands
|
||||
EE +5925+02445 Europe/Tallinn
|
||||
EG +3003+03115 Africa/Cairo
|
||||
EH +2709-01312 Africa/El_Aaiun
|
||||
ER +1520+03853 Africa/Asmara
|
||||
ES +4024-00341 Europe/Madrid mainland
|
||||
ES +3553-00519 Africa/Ceuta Ceuta & Melilla
|
||||
ES +2806-01524 Atlantic/Canary Canary Islands
|
||||
ET +0902+03842 Africa/Addis_Ababa
|
||||
FI +6010+02458 Europe/Helsinki
|
||||
FJ -1808+17825 Pacific/Fiji
|
||||
FK -5142-05751 Atlantic/Stanley
|
||||
FM +0725+15147 Pacific/Chuuk Chuuk (Truk) and Yap
|
||||
FM +0658+15813 Pacific/Pohnpei Pohnpei (Ponape)
|
||||
FM +0519+16259 Pacific/Kosrae Kosrae
|
||||
FO +6201-00646 Atlantic/Faroe
|
||||
FR +4852+00220 Europe/Paris
|
||||
GA +0023+00927 Africa/Libreville
|
||||
GB +513030-0000731 Europe/London
|
||||
GD +1203-06145 America/Grenada
|
||||
GE +4143+04449 Asia/Tbilisi
|
||||
GF +0456-05220 America/Cayenne
|
||||
GG +4927-00232 Europe/Guernsey
|
||||
GH +0533-00013 Africa/Accra
|
||||
GI +3608-00521 Europe/Gibraltar
|
||||
GL +6411-05144 America/Godthab most locations
|
||||
GL +7646-01840 America/Danmarkshavn east coast, north of Scoresbysund
|
||||
GL +7029-02158 America/Scoresbysund Scoresbysund / Ittoqqortoormiit
|
||||
GL +7634-06847 America/Thule Thule / Pituffik
|
||||
GM +1328-01639 Africa/Banjul
|
||||
GN +0931-01343 Africa/Conakry
|
||||
GP +1614-06132 America/Guadeloupe
|
||||
GQ +0345+00847 Africa/Malabo
|
||||
GR +3758+02343 Europe/Athens
|
||||
GS -5416-03632 Atlantic/South_Georgia
|
||||
GT +1438-09031 America/Guatemala
|
||||
GU +1328+14445 Pacific/Guam
|
||||
GW +1151-01535 Africa/Bissau
|
||||
GY +0648-05810 America/Guyana
|
||||
HK +2217+11409 Asia/Hong_Kong
|
||||
HN +1406-08713 America/Tegucigalpa
|
||||
HR +4548+01558 Europe/Zagreb
|
||||
HT +1832-07220 America/Port-au-Prince
|
||||
HU +4730+01905 Europe/Budapest
|
||||
ID -0610+10648 Asia/Jakarta Java & Sumatra
|
||||
ID -0002+10920 Asia/Pontianak west & central Borneo
|
||||
ID -0507+11924 Asia/Makassar east & south Borneo, Sulawesi (Celebes), Bali, Nusa Tengarra, west Timor
|
||||
ID -0232+14042 Asia/Jayapura west New Guinea (Irian Jaya) & Malukus (Moluccas)
|
||||
IE +5320-00615 Europe/Dublin
|
||||
IL +314650+0351326 Asia/Jerusalem
|
||||
IM +5409-00428 Europe/Isle_of_Man
|
||||
IN +2232+08822 Asia/Kolkata
|
||||
IO -0720+07225 Indian/Chagos
|
||||
IQ +3321+04425 Asia/Baghdad
|
||||
IR +3540+05126 Asia/Tehran
|
||||
IS +6409-02151 Atlantic/Reykjavik
|
||||
IT +4154+01229 Europe/Rome
|
||||
JE +4912-00207 Europe/Jersey
|
||||
JM +175805-0764736 America/Jamaica
|
||||
JO +3157+03556 Asia/Amman
|
||||
JP +353916+1394441 Asia/Tokyo
|
||||
KE -0117+03649 Africa/Nairobi
|
||||
KG +4254+07436 Asia/Bishkek
|
||||
KH +1133+10455 Asia/Phnom_Penh
|
||||
KI +0125+17300 Pacific/Tarawa Gilbert Islands
|
||||
KI -0308-17105 Pacific/Enderbury Phoenix Islands
|
||||
KI +0152-15720 Pacific/Kiritimati Line Islands
|
||||
KM -1141+04316 Indian/Comoro
|
||||
KN +1718-06243 America/St_Kitts
|
||||
KP +3901+12545 Asia/Pyongyang
|
||||
KR +3733+12658 Asia/Seoul
|
||||
KW +2920+04759 Asia/Kuwait
|
||||
KY +1918-08123 America/Cayman
|
||||
KZ +4315+07657 Asia/Almaty most locations
|
||||
KZ +4448+06528 Asia/Qyzylorda Qyzylorda (Kyzylorda, Kzyl-Orda)
|
||||
KZ +5017+05710 Asia/Aqtobe Aqtobe (Aktobe)
|
||||
KZ +4431+05016 Asia/Aqtau Atyrau (Atirau, Gur'yev), Mangghystau (Mankistau)
|
||||
KZ +5113+05121 Asia/Oral West Kazakhstan
|
||||
LA +1758+10236 Asia/Vientiane
|
||||
LB +3353+03530 Asia/Beirut
|
||||
LC +1401-06100 America/St_Lucia
|
||||
LI +4709+00931 Europe/Vaduz
|
||||
LK +0656+07951 Asia/Colombo
|
||||
LR +0618-01047 Africa/Monrovia
|
||||
LS -2928+02730 Africa/Maseru
|
||||
LT +5441+02519 Europe/Vilnius
|
||||
LU +4936+00609 Europe/Luxembourg
|
||||
LV +5657+02406 Europe/Riga
|
||||
LY +3254+01311 Africa/Tripoli
|
||||
MA +3339-00735 Africa/Casablanca
|
||||
MC +4342+00723 Europe/Monaco
|
||||
MD +4700+02850 Europe/Chisinau
|
||||
ME +4226+01916 Europe/Podgorica
|
||||
MF +1804-06305 America/Marigot
|
||||
MG -1855+04731 Indian/Antananarivo
|
||||
MH +0709+17112 Pacific/Majuro most locations
|
||||
MH +0905+16720 Pacific/Kwajalein Kwajalein
|
||||
MK +4159+02126 Europe/Skopje
|
||||
ML +1239-00800 Africa/Bamako
|
||||
MM +1647+09610 Asia/Rangoon
|
||||
MN +4755+10653 Asia/Ulaanbaatar most locations
|
||||
MN +4801+09139 Asia/Hovd Bayan-Olgiy, Govi-Altai, Hovd, Uvs, Zavkhan
|
||||
MN +4804+11430 Asia/Choibalsan Dornod, Sukhbaatar
|
||||
MO +2214+11335 Asia/Macau
|
||||
MP +1512+14545 Pacific/Saipan
|
||||
MQ +1436-06105 America/Martinique
|
||||
MR +1806-01557 Africa/Nouakchott
|
||||
MS +1643-06213 America/Montserrat
|
||||
MT +3554+01431 Europe/Malta
|
||||
MU -2010+05730 Indian/Mauritius
|
||||
MV +0410+07330 Indian/Maldives
|
||||
MW -1547+03500 Africa/Blantyre
|
||||
MX +1924-09909 America/Mexico_City Central Time - most locations
|
||||
MX +2105-08646 America/Cancun Central Time - Quintana Roo
|
||||
MX +2058-08937 America/Merida Central Time - Campeche, Yucatan
|
||||
MX +2540-10019 America/Monterrey Mexican Central Time - Coahuila, Durango, Nuevo Leon, Tamaulipas away from US border
|
||||
MX +2550-09730 America/Matamoros US Central Time - Coahuila, Durango, Nuevo Leon, Tamaulipas near US border
|
||||
MX +2313-10625 America/Mazatlan Mountain Time - S Baja, Nayarit, Sinaloa
|
||||
MX +2838-10605 America/Chihuahua Mexican Mountain Time - Chihuahua away from US border
|
||||
MX +2934-10425 America/Ojinaga US Mountain Time - Chihuahua near US border
|
||||
MX +2904-11058 America/Hermosillo Mountain Standard Time - Sonora
|
||||
MX +3232-11701 America/Tijuana US Pacific Time - Baja California near US border
|
||||
MX +3018-11452 America/Santa_Isabel Mexican Pacific Time - Baja California away from US border
|
||||
MX +2048-10515 America/Bahia_Banderas Mexican Central Time - Bahia de Banderas
|
||||
MY +0310+10142 Asia/Kuala_Lumpur peninsular Malaysia
|
||||
MY +0133+11020 Asia/Kuching Sabah & Sarawak
|
||||
MZ -2558+03235 Africa/Maputo
|
||||
NA -2234+01706 Africa/Windhoek
|
||||
NC -2216+16627 Pacific/Noumea
|
||||
NE +1331+00207 Africa/Niamey
|
||||
NF -2903+16758 Pacific/Norfolk
|
||||
NG +0627+00324 Africa/Lagos
|
||||
NI +1209-08617 America/Managua
|
||||
NL +5222+00454 Europe/Amsterdam
|
||||
NO +5955+01045 Europe/Oslo
|
||||
NP +2743+08519 Asia/Kathmandu
|
||||
NR -0031+16655 Pacific/Nauru
|
||||
NU -1901-16955 Pacific/Niue
|
||||
NZ -3652+17446 Pacific/Auckland most locations
|
||||
NZ -4357-17633 Pacific/Chatham Chatham Islands
|
||||
OM +2336+05835 Asia/Muscat
|
||||
PA +0858-07932 America/Panama
|
||||
PE -1203-07703 America/Lima
|
||||
PF -1732-14934 Pacific/Tahiti Society Islands
|
||||
PF -0900-13930 Pacific/Marquesas Marquesas Islands
|
||||
PF -2308-13457 Pacific/Gambier Gambier Islands
|
||||
PG -0930+14710 Pacific/Port_Moresby
|
||||
PH +1435+12100 Asia/Manila
|
||||
PK +2452+06703 Asia/Karachi
|
||||
PL +5215+02100 Europe/Warsaw
|
||||
PM +4703-05620 America/Miquelon
|
||||
PN -2504-13005 Pacific/Pitcairn
|
||||
PR +182806-0660622 America/Puerto_Rico
|
||||
PS +3130+03428 Asia/Gaza Gaza Strip
|
||||
PS +313200+0350542 Asia/Hebron West Bank
|
||||
PT +3843-00908 Europe/Lisbon mainland
|
||||
PT +3238-01654 Atlantic/Madeira Madeira Islands
|
||||
PT +3744-02540 Atlantic/Azores Azores
|
||||
PW +0720+13429 Pacific/Palau
|
||||
PY -2516-05740 America/Asuncion
|
||||
QA +2517+05132 Asia/Qatar
|
||||
RE -2052+05528 Indian/Reunion
|
||||
RO +4426+02606 Europe/Bucharest
|
||||
RS +4450+02030 Europe/Belgrade
|
||||
RU +5443+02030 Europe/Kaliningrad Moscow-01 - Kaliningrad
|
||||
RU +5545+03735 Europe/Moscow Moscow+00 - west Russia
|
||||
RU +4844+04425 Europe/Volgograd Moscow+00 - Caspian Sea
|
||||
RU +5312+05009 Europe/Samara Moscow+00 - Samara, Udmurtia
|
||||
RU +4457+03406 Europe/Simferopol Moscow+00 - Crimea
|
||||
RU +5651+06036 Asia/Yekaterinburg Moscow+02 - Urals
|
||||
RU +5500+07324 Asia/Omsk Moscow+03 - west Siberia
|
||||
RU +5502+08255 Asia/Novosibirsk Moscow+03 - Novosibirsk
|
||||
RU +5345+08707 Asia/Novokuznetsk Moscow+03 - Novokuznetsk
|
||||
RU +5601+09250 Asia/Krasnoyarsk Moscow+04 - Yenisei River
|
||||
RU +5216+10420 Asia/Irkutsk Moscow+05 - Lake Baikal
|
||||
RU +6200+12940 Asia/Yakutsk Moscow+06 - Lena River
|
||||
RU +623923+1353314 Asia/Khandyga Moscow+06 - Tomponsky, Ust-Maysky
|
||||
RU +4310+13156 Asia/Vladivostok Moscow+07 - Amur River
|
||||
RU +4658+14242 Asia/Sakhalin Moscow+07 - Sakhalin Island
|
||||
RU +643337+1431336 Asia/Ust-Nera Moscow+07 - Oymyakonsky
|
||||
RU +5934+15048 Asia/Magadan Moscow+08 - Magadan
|
||||
RU +5301+15839 Asia/Kamchatka Moscow+08 - Kamchatka
|
||||
RU +6445+17729 Asia/Anadyr Moscow+08 - Bering Sea
|
||||
RW -0157+03004 Africa/Kigali
|
||||
SA +2438+04643 Asia/Riyadh
|
||||
SB -0932+16012 Pacific/Guadalcanal
|
||||
SC -0440+05528 Indian/Mahe
|
||||
SD +1536+03232 Africa/Khartoum
|
||||
SE +5920+01803 Europe/Stockholm
|
||||
SG +0117+10351 Asia/Singapore
|
||||
SH -1555-00542 Atlantic/St_Helena
|
||||
SI +4603+01431 Europe/Ljubljana
|
||||
SJ +7800+01600 Arctic/Longyearbyen
|
||||
SK +4809+01707 Europe/Bratislava
|
||||
SL +0830-01315 Africa/Freetown
|
||||
SM +4355+01228 Europe/San_Marino
|
||||
SN +1440-01726 Africa/Dakar
|
||||
SO +0204+04522 Africa/Mogadishu
|
||||
SR +0550-05510 America/Paramaribo
|
||||
SS +0451+03136 Africa/Juba
|
||||
ST +0020+00644 Africa/Sao_Tome
|
||||
SV +1342-08912 America/El_Salvador
|
||||
SX +180305-0630250 America/Lower_Princes
|
||||
SY +3330+03618 Asia/Damascus
|
||||
SZ -2618+03106 Africa/Mbabane
|
||||
TC +2128-07108 America/Grand_Turk
|
||||
TD +1207+01503 Africa/Ndjamena
|
||||
TF -492110+0701303 Indian/Kerguelen
|
||||
TG +0608+00113 Africa/Lome
|
||||
TH +1345+10031 Asia/Bangkok
|
||||
TJ +3835+06848 Asia/Dushanbe
|
||||
TK -0922-17114 Pacific/Fakaofo
|
||||
TL -0833+12535 Asia/Dili
|
||||
TM +3757+05823 Asia/Ashgabat
|
||||
TN +3648+01011 Africa/Tunis
|
||||
TO -2110-17510 Pacific/Tongatapu
|
||||
TR +4101+02858 Europe/Istanbul
|
||||
TT +1039-06131 America/Port_of_Spain
|
||||
TV -0831+17913 Pacific/Funafuti
|
||||
TW +2503+12130 Asia/Taipei
|
||||
TZ -0648+03917 Africa/Dar_es_Salaam
|
||||
UA +5026+03031 Europe/Kiev most locations
|
||||
UA +4837+02218 Europe/Uzhgorod Ruthenia
|
||||
UA +4750+03510 Europe/Zaporozhye Zaporozh'ye, E Lugansk / Zaporizhia, E Luhansk
|
||||
UG +0019+03225 Africa/Kampala
|
||||
UM +1645-16931 Pacific/Johnston Johnston Atoll
|
||||
UM +2813-17722 Pacific/Midway Midway Islands
|
||||
UM +1917+16637 Pacific/Wake Wake Island
|
||||
US +404251-0740023 America/New_York Eastern Time
|
||||
US +421953-0830245 America/Detroit Eastern Time - Michigan - most locations
|
||||
US +381515-0854534 America/Kentucky/Louisville Eastern Time - Kentucky - Louisville area
|
||||
US +364947-0845057 America/Kentucky/Monticello Eastern Time - Kentucky - Wayne County
|
||||
US +394606-0860929 America/Indiana/Indianapolis Eastern Time - Indiana - most locations
|
||||
US +384038-0873143 America/Indiana/Vincennes Eastern Time - Indiana - Daviess, Dubois, Knox & Martin Counties
|
||||
US +410305-0863611 America/Indiana/Winamac Eastern Time - Indiana - Pulaski County
|
||||
US +382232-0862041 America/Indiana/Marengo Eastern Time - Indiana - Crawford County
|
||||
US +382931-0871643 America/Indiana/Petersburg Eastern Time - Indiana - Pike County
|
||||
US +384452-0850402 America/Indiana/Vevay Eastern Time - Indiana - Switzerland County
|
||||
US +415100-0873900 America/Chicago Central Time
|
||||
US +375711-0864541 America/Indiana/Tell_City Central Time - Indiana - Perry County
|
||||
US +411745-0863730 America/Indiana/Knox Central Time - Indiana - Starke County
|
||||
US +450628-0873651 America/Menominee Central Time - Michigan - Dickinson, Gogebic, Iron & Menominee Counties
|
||||
US +470659-1011757 America/North_Dakota/Center Central Time - North Dakota - Oliver County
|
||||
US +465042-1012439 America/North_Dakota/New_Salem Central Time - North Dakota - Morton County (except Mandan area)
|
||||
US +471551-1014640 America/North_Dakota/Beulah Central Time - North Dakota - Mercer County
|
||||
US +394421-1045903 America/Denver Mountain Time
|
||||
US +433649-1161209 America/Boise Mountain Time - south Idaho & east Oregon
|
||||
US +332654-1120424 America/Phoenix Mountain Standard Time - Arizona (except Navajo)
|
||||
US +340308-1181434 America/Los_Angeles Pacific Time
|
||||
US +611305-1495401 America/Anchorage Alaska Time
|
||||
US +581807-1342511 America/Juneau Alaska Time - Alaska panhandle
|
||||
US +571035-1351807 America/Sitka Alaska Time - southeast Alaska panhandle
|
||||
US +593249-1394338 America/Yakutat Alaska Time - Alaska panhandle neck
|
||||
US +643004-1652423 America/Nome Alaska Time - west Alaska
|
||||
US +515248-1763929 America/Adak Aleutian Islands
|
||||
US +550737-1313435 America/Metlakatla Metlakatla Time - Annette Island
|
||||
US +211825-1575130 Pacific/Honolulu Hawaii
|
||||
UY -3453-05611 America/Montevideo
|
||||
UZ +3940+06648 Asia/Samarkand west Uzbekistan
|
||||
UZ +4120+06918 Asia/Tashkent east Uzbekistan
|
||||
VA +415408+0122711 Europe/Vatican
|
||||
VC +1309-06114 America/St_Vincent
|
||||
VE +1030-06656 America/Caracas
|
||||
VG +1827-06437 America/Tortola
|
||||
VI +1821-06456 America/St_Thomas
|
||||
VN +1045+10640 Asia/Ho_Chi_Minh
|
||||
VU -1740+16825 Pacific/Efate
|
||||
WF -1318-17610 Pacific/Wallis
|
||||
WS -1350-17144 Pacific/Apia
|
||||
YE +1245+04512 Asia/Aden
|
||||
YT -1247+04514 Indian/Mayotte
|
||||
ZA -2615+02800 Africa/Johannesburg
|
||||
ZM -1525+02817 Africa/Lusaka
|
||||
ZW -1750+03103 Africa/Harare
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,275 +0,0 @@
|
|||
# ISO 3166 alpha-2 country codes
|
||||
#
|
||||
# This file is in the public domain, so clarified as of
|
||||
# 2009-05-17 by Arthur David Olson.
|
||||
#
|
||||
# From Paul Eggert (2014-07-18):
|
||||
# This file contains a table of two-letter country codes. Columns are
|
||||
# separated by a single tab. Lines beginning with '#' are comments.
|
||||
# Although all text currently uses ASCII encoding, this is planned to
|
||||
# change to UTF-8 soon. The columns of the table are as follows:
|
||||
#
|
||||
# 1. ISO 3166-1 alpha-2 country code, current as of
|
||||
# ISO 3166-1 Newsletter VI-16 (2013-07-11). See: Updates on ISO 3166
|
||||
# http://www.iso.org/iso/home/standards/country_codes/updates_on_iso_3166.htm
|
||||
# 2. The usual English name for the coded region,
|
||||
# chosen so that alphabetic sorting of subsets produces helpful lists.
|
||||
# This is not the same as the English name in the ISO 3166 tables.
|
||||
#
|
||||
# The table is sorted by country code.
|
||||
#
|
||||
# This table is intended as an aid for users, to help them select time
|
||||
# zone data appropriate for their practical needs. It is not intended
|
||||
# to take or endorse any position on legal or territorial claims.
|
||||
#
|
||||
#country-
|
||||
#code name of country, territory, area, or subdivision
|
||||
AD Andorra
|
||||
AE United Arab Emirates
|
||||
AF Afghanistan
|
||||
AG Antigua & Barbuda
|
||||
AI Anguilla
|
||||
AL Albania
|
||||
AM Armenia
|
||||
AO Angola
|
||||
AQ Antarctica
|
||||
AR Argentina
|
||||
AS Samoa (American)
|
||||
AT Austria
|
||||
AU Australia
|
||||
AW Aruba
|
||||
AX Aaland Islands
|
||||
AZ Azerbaijan
|
||||
BA Bosnia & Herzegovina
|
||||
BB Barbados
|
||||
BD Bangladesh
|
||||
BE Belgium
|
||||
BF Burkina Faso
|
||||
BG Bulgaria
|
||||
BH Bahrain
|
||||
BI Burundi
|
||||
BJ Benin
|
||||
BL St Barthelemy
|
||||
BM Bermuda
|
||||
BN Brunei
|
||||
BO Bolivia
|
||||
BQ Caribbean Netherlands
|
||||
BR Brazil
|
||||
BS Bahamas
|
||||
BT Bhutan
|
||||
BV Bouvet Island
|
||||
BW Botswana
|
||||
BY Belarus
|
||||
BZ Belize
|
||||
CA Canada
|
||||
CC Cocos (Keeling) Islands
|
||||
CD Congo (Dem. Rep.)
|
||||
CF Central African Rep.
|
||||
CG Congo (Rep.)
|
||||
CH Switzerland
|
||||
CI Cote d'Ivoire
|
||||
CK Cook Islands
|
||||
CL Chile
|
||||
CM Cameroon
|
||||
CN China
|
||||
CO Colombia
|
||||
CR Costa Rica
|
||||
CU Cuba
|
||||
CV Cape Verde
|
||||
CW Curacao
|
||||
CX Christmas Island
|
||||
CY Cyprus
|
||||
CZ Czech Republic
|
||||
DE Germany
|
||||
DJ Djibouti
|
||||
DK Denmark
|
||||
DM Dominica
|
||||
DO Dominican Republic
|
||||
DZ Algeria
|
||||
EC Ecuador
|
||||
EE Estonia
|
||||
EG Egypt
|
||||
EH Western Sahara
|
||||
ER Eritrea
|
||||
ES Spain
|
||||
ET Ethiopia
|
||||
FI Finland
|
||||
FJ Fiji
|
||||
FK Falkland Islands
|
||||
FM Micronesia
|
||||
FO Faroe Islands
|
||||
FR France
|
||||
GA Gabon
|
||||
GB Britain (UK)
|
||||
GD Grenada
|
||||
GE Georgia
|
||||
GF French Guiana
|
||||
GG Guernsey
|
||||
GH Ghana
|
||||
GI Gibraltar
|
||||
GL Greenland
|
||||
GM Gambia
|
||||
GN Guinea
|
||||
GP Guadeloupe
|
||||
GQ Equatorial Guinea
|
||||
GR Greece
|
||||
GS South Georgia & the South Sandwich Islands
|
||||
GT Guatemala
|
||||
GU Guam
|
||||
GW Guinea-Bissau
|
||||
GY Guyana
|
||||
HK Hong Kong
|
||||
HM Heard Island & McDonald Islands
|
||||
HN Honduras
|
||||
HR Croatia
|
||||
HT Haiti
|
||||
HU Hungary
|
||||
ID Indonesia
|
||||
IE Ireland
|
||||
IL Israel
|
||||
IM Isle of Man
|
||||
IN India
|
||||
IO British Indian Ocean Territory
|
||||
IQ Iraq
|
||||
IR Iran
|
||||
IS Iceland
|
||||
IT Italy
|
||||
JE Jersey
|
||||
JM Jamaica
|
||||
JO Jordan
|
||||
JP Japan
|
||||
KE Kenya
|
||||
KG Kyrgyzstan
|
||||
KH Cambodia
|
||||
KI Kiribati
|
||||
KM Comoros
|
||||
KN St Kitts & Nevis
|
||||
KP Korea (North)
|
||||
KR Korea (South)
|
||||
KW Kuwait
|
||||
KY Cayman Islands
|
||||
KZ Kazakhstan
|
||||
LA Laos
|
||||
LB Lebanon
|
||||
LC St Lucia
|
||||
LI Liechtenstein
|
||||
LK Sri Lanka
|
||||
LR Liberia
|
||||
LS Lesotho
|
||||
LT Lithuania
|
||||
LU Luxembourg
|
||||
LV Latvia
|
||||
LY Libya
|
||||
MA Morocco
|
||||
MC Monaco
|
||||
MD Moldova
|
||||
ME Montenegro
|
||||
MF St Martin (French part)
|
||||
MG Madagascar
|
||||
MH Marshall Islands
|
||||
MK Macedonia
|
||||
ML Mali
|
||||
MM Myanmar (Burma)
|
||||
MN Mongolia
|
||||
MO Macau
|
||||
MP Northern Mariana Islands
|
||||
MQ Martinique
|
||||
MR Mauritania
|
||||
MS Montserrat
|
||||
MT Malta
|
||||
MU Mauritius
|
||||
MV Maldives
|
||||
MW Malawi
|
||||
MX Mexico
|
||||
MY Malaysia
|
||||
MZ Mozambique
|
||||
NA Namibia
|
||||
NC New Caledonia
|
||||
NE Niger
|
||||
NF Norfolk Island
|
||||
NG Nigeria
|
||||
NI Nicaragua
|
||||
NL Netherlands
|
||||
NO Norway
|
||||
NP Nepal
|
||||
NR Nauru
|
||||
NU Niue
|
||||
NZ New Zealand
|
||||
OM Oman
|
||||
PA Panama
|
||||
PE Peru
|
||||
PF French Polynesia
|
||||
PG Papua New Guinea
|
||||
PH Philippines
|
||||
PK Pakistan
|
||||
PL Poland
|
||||
PM St Pierre & Miquelon
|
||||
PN Pitcairn
|
||||
PR Puerto Rico
|
||||
PS Palestine
|
||||
PT Portugal
|
||||
PW Palau
|
||||
PY Paraguay
|
||||
QA Qatar
|
||||
RE Reunion
|
||||
RO Romania
|
||||
RS Serbia
|
||||
RU Russia
|
||||
RW Rwanda
|
||||
SA Saudi Arabia
|
||||
SB Solomon Islands
|
||||
SC Seychelles
|
||||
SD Sudan
|
||||
SE Sweden
|
||||
SG Singapore
|
||||
SH St Helena
|
||||
SI Slovenia
|
||||
SJ Svalbard & Jan Mayen
|
||||
SK Slovakia
|
||||
SL Sierra Leone
|
||||
SM San Marino
|
||||
SN Senegal
|
||||
SO Somalia
|
||||
SR Suriname
|
||||
SS South Sudan
|
||||
ST Sao Tome & Principe
|
||||
SV El Salvador
|
||||
SX St Maarten (Dutch part)
|
||||
SY Syria
|
||||
SZ Swaziland
|
||||
TC Turks & Caicos Is
|
||||
TD Chad
|
||||
TF French Southern & Antarctic Lands
|
||||
TG Togo
|
||||
TH Thailand
|
||||
TJ Tajikistan
|
||||
TK Tokelau
|
||||
TL East Timor
|
||||
TM Turkmenistan
|
||||
TN Tunisia
|
||||
TO Tonga
|
||||
TR Turkey
|
||||
TT Trinidad & Tobago
|
||||
TV Tuvalu
|
||||
TW Taiwan
|
||||
TZ Tanzania
|
||||
UA Ukraine
|
||||
UG Uganda
|
||||
UM US minor outlying islands
|
||||
US United States
|
||||
UY Uruguay
|
||||
UZ Uzbekistan
|
||||
VA Vatican City
|
||||
VC St Vincent
|
||||
VE Venezuela
|
||||
VG Virgin Islands (UK)
|
||||
VI Virgin Islands (US)
|
||||
VN Vietnam
|
||||
VU Vanuatu
|
||||
WF Wallis & Futuna
|
||||
WS Samoa (western)
|
||||
YE Yemen
|
||||
YT Mayotte
|
||||
ZA South Africa
|
||||
ZM Zambia
|
||||
ZW Zimbabwe
|
Binary file not shown.
Binary file not shown.
|
@ -1,439 +0,0 @@
|
|||
# tz zone descriptions (deprecated version)
|
||||
#
|
||||
# This file is in the public domain, so clarified as of
|
||||
# 2009-05-17 by Arthur David Olson.
|
||||
#
|
||||
# From Paul Eggert (2014-07-31):
|
||||
# This file is intended as a backward-compatibility aid for older programs.
|
||||
# New programs should use zone1970.tab. This file is like zone1970.tab (see
|
||||
# zone1970.tab's comments), but with the following additional restrictions:
|
||||
#
|
||||
# 1. This file contains only ASCII characters.
|
||||
# 2. The first data column contains exactly one country code.
|
||||
#
|
||||
# Because of (2), each row stands for an area that is the intersection
|
||||
# of a region identified by a country code and of a zone where civil
|
||||
# clocks have agreed since 1970; this is a narrower definition than
|
||||
# that of zone1970.tab.
|
||||
#
|
||||
# This table is intended as an aid for users, to help them select time
|
||||
# zone data appropriate for their practical needs. It is not intended
|
||||
# to take or endorse any position on legal or territorial claims.
|
||||
#
|
||||
#country-
|
||||
#code coordinates TZ comments
|
||||
AD +4230+00131 Europe/Andorra
|
||||
AE +2518+05518 Asia/Dubai
|
||||
AF +3431+06912 Asia/Kabul
|
||||
AG +1703-06148 America/Antigua
|
||||
AI +1812-06304 America/Anguilla
|
||||
AL +4120+01950 Europe/Tirane
|
||||
AM +4011+04430 Asia/Yerevan
|
||||
AO -0848+01314 Africa/Luanda
|
||||
AQ -7750+16636 Antarctica/McMurdo McMurdo, South Pole, Scott (New Zealand time)
|
||||
AQ -6734-06808 Antarctica/Rothera Rothera Station, Adelaide Island
|
||||
AQ -6448-06406 Antarctica/Palmer Palmer Station, Anvers Island
|
||||
AQ -6736+06253 Antarctica/Mawson Mawson Station, Holme Bay
|
||||
AQ -6835+07758 Antarctica/Davis Davis Station, Vestfold Hills
|
||||
AQ -6617+11031 Antarctica/Casey Casey Station, Bailey Peninsula
|
||||
AQ -7824+10654 Antarctica/Vostok Vostok Station, Lake Vostok
|
||||
AQ -6640+14001 Antarctica/DumontDUrville Dumont-d'Urville Station, Terre Adelie
|
||||
AQ -690022+0393524 Antarctica/Syowa Syowa Station, E Ongul I
|
||||
AQ -720041+0023206 Antarctica/Troll Troll Station, Queen Maud Land
|
||||
AR -3436-05827 America/Argentina/Buenos_Aires Buenos Aires (BA, CF)
|
||||
AR -3124-06411 America/Argentina/Cordoba most locations (CB, CC, CN, ER, FM, MN, SE, SF)
|
||||
AR -2447-06525 America/Argentina/Salta (SA, LP, NQ, RN)
|
||||
AR -2411-06518 America/Argentina/Jujuy Jujuy (JY)
|
||||
AR -2649-06513 America/Argentina/Tucuman Tucuman (TM)
|
||||
AR -2828-06547 America/Argentina/Catamarca Catamarca (CT), Chubut (CH)
|
||||
AR -2926-06651 America/Argentina/La_Rioja La Rioja (LR)
|
||||
AR -3132-06831 America/Argentina/San_Juan San Juan (SJ)
|
||||
AR -3253-06849 America/Argentina/Mendoza Mendoza (MZ)
|
||||
AR -3319-06621 America/Argentina/San_Luis San Luis (SL)
|
||||
AR -5138-06913 America/Argentina/Rio_Gallegos Santa Cruz (SC)
|
||||
AR -5448-06818 America/Argentina/Ushuaia Tierra del Fuego (TF)
|
||||
AS -1416-17042 Pacific/Pago_Pago
|
||||
AT +4813+01620 Europe/Vienna
|
||||
AU -3133+15905 Australia/Lord_Howe Lord Howe Island
|
||||
AU -5430+15857 Antarctica/Macquarie Macquarie Island
|
||||
AU -4253+14719 Australia/Hobart Tasmania - most locations
|
||||
AU -3956+14352 Australia/Currie Tasmania - King Island
|
||||
AU -3749+14458 Australia/Melbourne Victoria
|
||||
AU -3352+15113 Australia/Sydney New South Wales - most locations
|
||||
AU -3157+14127 Australia/Broken_Hill New South Wales - Yancowinna
|
||||
AU -2728+15302 Australia/Brisbane Queensland - most locations
|
||||
AU -2016+14900 Australia/Lindeman Queensland - Holiday Islands
|
||||
AU -3455+13835 Australia/Adelaide South Australia
|
||||
AU -1228+13050 Australia/Darwin Northern Territory
|
||||
AU -3157+11551 Australia/Perth Western Australia - most locations
|
||||
AU -3143+12852 Australia/Eucla Western Australia - Eucla area
|
||||
AW +1230-06958 America/Aruba
|
||||
AX +6006+01957 Europe/Mariehamn
|
||||
AZ +4023+04951 Asia/Baku
|
||||
BA +4352+01825 Europe/Sarajevo
|
||||
BB +1306-05937 America/Barbados
|
||||
BD +2343+09025 Asia/Dhaka
|
||||
BE +5050+00420 Europe/Brussels
|
||||
BF +1222-00131 Africa/Ouagadougou
|
||||
BG +4241+02319 Europe/Sofia
|
||||
BH +2623+05035 Asia/Bahrain
|
||||
BI -0323+02922 Africa/Bujumbura
|
||||
BJ +0629+00237 Africa/Porto-Novo
|
||||
BL +1753-06251 America/St_Barthelemy
|
||||
BM +3217-06446 Atlantic/Bermuda
|
||||
BN +0456+11455 Asia/Brunei
|
||||
BO -1630-06809 America/La_Paz
|
||||
BQ +120903-0681636 America/Kralendijk
|
||||
BR -0351-03225 America/Noronha Atlantic islands
|
||||
BR -0127-04829 America/Belem Amapa, E Para
|
||||
BR -0343-03830 America/Fortaleza NE Brazil (MA, PI, CE, RN, PB)
|
||||
BR -0803-03454 America/Recife Pernambuco
|
||||
BR -0712-04812 America/Araguaina Tocantins
|
||||
BR -0940-03543 America/Maceio Alagoas, Sergipe
|
||||
BR -1259-03831 America/Bahia Bahia
|
||||
BR -2332-04637 America/Sao_Paulo S & SE Brazil (GO, DF, MG, ES, RJ, SP, PR, SC, RS)
|
||||
BR -2027-05437 America/Campo_Grande Mato Grosso do Sul
|
||||
BR -1535-05605 America/Cuiaba Mato Grosso
|
||||
BR -0226-05452 America/Santarem W Para
|
||||
BR -0846-06354 America/Porto_Velho Rondonia
|
||||
BR +0249-06040 America/Boa_Vista Roraima
|
||||
BR -0308-06001 America/Manaus E Amazonas
|
||||
BR -0640-06952 America/Eirunepe W Amazonas
|
||||
BR -0958-06748 America/Rio_Branco Acre
|
||||
BS +2505-07721 America/Nassau
|
||||
BT +2728+08939 Asia/Thimphu
|
||||
BW -2439+02555 Africa/Gaborone
|
||||
BY +5354+02734 Europe/Minsk
|
||||
BZ +1730-08812 America/Belize
|
||||
CA +4734-05243 America/St_Johns Newfoundland Time, including SE Labrador
|
||||
CA +4439-06336 America/Halifax Atlantic Time - Nova Scotia (most places), PEI
|
||||
CA +4612-05957 America/Glace_Bay Atlantic Time - Nova Scotia - places that did not observe DST 1966-1971
|
||||
CA +4606-06447 America/Moncton Atlantic Time - New Brunswick
|
||||
CA +5320-06025 America/Goose_Bay Atlantic Time - Labrador - most locations
|
||||
CA +5125-05707 America/Blanc-Sablon Atlantic Standard Time - Quebec - Lower North Shore
|
||||
CA +4339-07923 America/Toronto Eastern Time - Ontario & Quebec - most locations
|
||||
CA +4901-08816 America/Nipigon Eastern Time - Ontario & Quebec - places that did not observe DST 1967-1973
|
||||
CA +4823-08915 America/Thunder_Bay Eastern Time - Thunder Bay, Ontario
|
||||
CA +6344-06828 America/Iqaluit Eastern Time - east Nunavut - most locations
|
||||
CA +6608-06544 America/Pangnirtung Eastern Time - Pangnirtung, Nunavut
|
||||
CA +744144-0944945 America/Resolute Central Time - Resolute, Nunavut
|
||||
CA +484531-0913718 America/Atikokan Eastern Standard Time - Atikokan, Ontario and Southampton I, Nunavut
|
||||
CA +624900-0920459 America/Rankin_Inlet Central Time - central Nunavut
|
||||
CA +4953-09709 America/Winnipeg Central Time - Manitoba & west Ontario
|
||||
CA +4843-09434 America/Rainy_River Central Time - Rainy River & Fort Frances, Ontario
|
||||
CA +5024-10439 America/Regina Central Standard Time - Saskatchewan - most locations
|
||||
CA +5017-10750 America/Swift_Current Central Standard Time - Saskatchewan - midwest
|
||||
CA +5333-11328 America/Edmonton Mountain Time - Alberta, east British Columbia & west Saskatchewan
|
||||
CA +690650-1050310 America/Cambridge_Bay Mountain Time - west Nunavut
|
||||
CA +6227-11421 America/Yellowknife Mountain Time - central Northwest Territories
|
||||
CA +682059-1334300 America/Inuvik Mountain Time - west Northwest Territories
|
||||
CA +4906-11631 America/Creston Mountain Standard Time - Creston, British Columbia
|
||||
CA +5946-12014 America/Dawson_Creek Mountain Standard Time - Dawson Creek & Fort Saint John, British Columbia
|
||||
CA +4916-12307 America/Vancouver Pacific Time - west British Columbia
|
||||
CA +6043-13503 America/Whitehorse Pacific Time - south Yukon
|
||||
CA +6404-13925 America/Dawson Pacific Time - north Yukon
|
||||
CC -1210+09655 Indian/Cocos
|
||||
CD -0418+01518 Africa/Kinshasa west Dem. Rep. of Congo
|
||||
CD -1140+02728 Africa/Lubumbashi east Dem. Rep. of Congo
|
||||
CF +0422+01835 Africa/Bangui
|
||||
CG -0416+01517 Africa/Brazzaville
|
||||
CH +4723+00832 Europe/Zurich
|
||||
CI +0519-00402 Africa/Abidjan
|
||||
CK -2114-15946 Pacific/Rarotonga
|
||||
CL -3327-07040 America/Santiago most locations
|
||||
CL -2709-10926 Pacific/Easter Easter Island
|
||||
CM +0403+00942 Africa/Douala
|
||||
CN +3114+12128 Asia/Shanghai Beijing Time
|
||||
CN +4348+08735 Asia/Urumqi Xinjiang Time
|
||||
CO +0436-07405 America/Bogota
|
||||
CR +0956-08405 America/Costa_Rica
|
||||
CU +2308-08222 America/Havana
|
||||
CV +1455-02331 Atlantic/Cape_Verde
|
||||
CW +1211-06900 America/Curacao
|
||||
CX -1025+10543 Indian/Christmas
|
||||
CY +3510+03322 Asia/Nicosia
|
||||
CZ +5005+01426 Europe/Prague
|
||||
DE +5230+01322 Europe/Berlin most locations
|
||||
DE +4742+00841 Europe/Busingen Busingen
|
||||
DJ +1136+04309 Africa/Djibouti
|
||||
DK +5540+01235 Europe/Copenhagen
|
||||
DM +1518-06124 America/Dominica
|
||||
DO +1828-06954 America/Santo_Domingo
|
||||
DZ +3647+00303 Africa/Algiers
|
||||
EC -0210-07950 America/Guayaquil mainland
|
||||
EC -0054-08936 Pacific/Galapagos Galapagos Islands
|
||||
EE +5925+02445 Europe/Tallinn
|
||||
EG +3003+03115 Africa/Cairo
|
||||
EH +2709-01312 Africa/El_Aaiun
|
||||
ER +1520+03853 Africa/Asmara
|
||||
ES +4024-00341 Europe/Madrid mainland
|
||||
ES +3553-00519 Africa/Ceuta Ceuta & Melilla
|
||||
ES +2806-01524 Atlantic/Canary Canary Islands
|
||||
ET +0902+03842 Africa/Addis_Ababa
|
||||
FI +6010+02458 Europe/Helsinki
|
||||
FJ -1808+17825 Pacific/Fiji
|
||||
FK -5142-05751 Atlantic/Stanley
|
||||
FM +0725+15147 Pacific/Chuuk Chuuk (Truk) and Yap
|
||||
FM +0658+15813 Pacific/Pohnpei Pohnpei (Ponape)
|
||||
FM +0519+16259 Pacific/Kosrae Kosrae
|
||||
FO +6201-00646 Atlantic/Faroe
|
||||
FR +4852+00220 Europe/Paris
|
||||
GA +0023+00927 Africa/Libreville
|
||||
GB +513030-0000731 Europe/London
|
||||
GD +1203-06145 America/Grenada
|
||||
GE +4143+04449 Asia/Tbilisi
|
||||
GF +0456-05220 America/Cayenne
|
||||
GG +4927-00232 Europe/Guernsey
|
||||
GH +0533-00013 Africa/Accra
|
||||
GI +3608-00521 Europe/Gibraltar
|
||||
GL +6411-05144 America/Godthab most locations
|
||||
GL +7646-01840 America/Danmarkshavn east coast, north of Scoresbysund
|
||||
GL +7029-02158 America/Scoresbysund Scoresbysund / Ittoqqortoormiit
|
||||
GL +7634-06847 America/Thule Thule / Pituffik
|
||||
GM +1328-01639 Africa/Banjul
|
||||
GN +0931-01343 Africa/Conakry
|
||||
GP +1614-06132 America/Guadeloupe
|
||||
GQ +0345+00847 Africa/Malabo
|
||||
GR +3758+02343 Europe/Athens
|
||||
GS -5416-03632 Atlantic/South_Georgia
|
||||
GT +1438-09031 America/Guatemala
|
||||
GU +1328+14445 Pacific/Guam
|
||||
GW +1151-01535 Africa/Bissau
|
||||
GY +0648-05810 America/Guyana
|
||||
HK +2217+11409 Asia/Hong_Kong
|
||||
HN +1406-08713 America/Tegucigalpa
|
||||
HR +4548+01558 Europe/Zagreb
|
||||
HT +1832-07220 America/Port-au-Prince
|
||||
HU +4730+01905 Europe/Budapest
|
||||
ID -0610+10648 Asia/Jakarta Java & Sumatra
|
||||
ID -0002+10920 Asia/Pontianak west & central Borneo
|
||||
ID -0507+11924 Asia/Makassar east & south Borneo, Sulawesi (Celebes), Bali, Nusa Tengarra, west Timor
|
||||
ID -0232+14042 Asia/Jayapura west New Guinea (Irian Jaya) & Malukus (Moluccas)
|
||||
IE +5320-00615 Europe/Dublin
|
||||
IL +314650+0351326 Asia/Jerusalem
|
||||
IM +5409-00428 Europe/Isle_of_Man
|
||||
IN +2232+08822 Asia/Kolkata
|
||||
IO -0720+07225 Indian/Chagos
|
||||
IQ +3321+04425 Asia/Baghdad
|
||||
IR +3540+05126 Asia/Tehran
|
||||
IS +6409-02151 Atlantic/Reykjavik
|
||||
IT +4154+01229 Europe/Rome
|
||||
JE +4912-00207 Europe/Jersey
|
||||
JM +175805-0764736 America/Jamaica
|
||||
JO +3157+03556 Asia/Amman
|
||||
JP +353916+1394441 Asia/Tokyo
|
||||
KE -0117+03649 Africa/Nairobi
|
||||
KG +4254+07436 Asia/Bishkek
|
||||
KH +1133+10455 Asia/Phnom_Penh
|
||||
KI +0125+17300 Pacific/Tarawa Gilbert Islands
|
||||
KI -0308-17105 Pacific/Enderbury Phoenix Islands
|
||||
KI +0152-15720 Pacific/Kiritimati Line Islands
|
||||
KM -1141+04316 Indian/Comoro
|
||||
KN +1718-06243 America/St_Kitts
|
||||
KP +3901+12545 Asia/Pyongyang
|
||||
KR +3733+12658 Asia/Seoul
|
||||
KW +2920+04759 Asia/Kuwait
|
||||
KY +1918-08123 America/Cayman
|
||||
KZ +4315+07657 Asia/Almaty most locations
|
||||
KZ +4448+06528 Asia/Qyzylorda Qyzylorda (Kyzylorda, Kzyl-Orda)
|
||||
KZ +5017+05710 Asia/Aqtobe Aqtobe (Aktobe)
|
||||
KZ +4431+05016 Asia/Aqtau Atyrau (Atirau, Gur'yev), Mangghystau (Mankistau)
|
||||
KZ +5113+05121 Asia/Oral West Kazakhstan
|
||||
LA +1758+10236 Asia/Vientiane
|
||||
LB +3353+03530 Asia/Beirut
|
||||
LC +1401-06100 America/St_Lucia
|
||||
LI +4709+00931 Europe/Vaduz
|
||||
LK +0656+07951 Asia/Colombo
|
||||
LR +0618-01047 Africa/Monrovia
|
||||
LS -2928+02730 Africa/Maseru
|
||||
LT +5441+02519 Europe/Vilnius
|
||||
LU +4936+00609 Europe/Luxembourg
|
||||
LV +5657+02406 Europe/Riga
|
||||
LY +3254+01311 Africa/Tripoli
|
||||
MA +3339-00735 Africa/Casablanca
|
||||
MC +4342+00723 Europe/Monaco
|
||||
MD +4700+02850 Europe/Chisinau
|
||||
ME +4226+01916 Europe/Podgorica
|
||||
MF +1804-06305 America/Marigot
|
||||
MG -1855+04731 Indian/Antananarivo
|
||||
MH +0709+17112 Pacific/Majuro most locations
|
||||
MH +0905+16720 Pacific/Kwajalein Kwajalein
|
||||
MK +4159+02126 Europe/Skopje
|
||||
ML +1239-00800 Africa/Bamako
|
||||
MM +1647+09610 Asia/Rangoon
|
||||
MN +4755+10653 Asia/Ulaanbaatar most locations
|
||||
MN +4801+09139 Asia/Hovd Bayan-Olgiy, Govi-Altai, Hovd, Uvs, Zavkhan
|
||||
MN +4804+11430 Asia/Choibalsan Dornod, Sukhbaatar
|
||||
MO +2214+11335 Asia/Macau
|
||||
MP +1512+14545 Pacific/Saipan
|
||||
MQ +1436-06105 America/Martinique
|
||||
MR +1806-01557 Africa/Nouakchott
|
||||
MS +1643-06213 America/Montserrat
|
||||
MT +3554+01431 Europe/Malta
|
||||
MU -2010+05730 Indian/Mauritius
|
||||
MV +0410+07330 Indian/Maldives
|
||||
MW -1547+03500 Africa/Blantyre
|
||||
MX +1924-09909 America/Mexico_City Central Time - most locations
|
||||
MX +2105-08646 America/Cancun Central Time - Quintana Roo
|
||||
MX +2058-08937 America/Merida Central Time - Campeche, Yucatan
|
||||
MX +2540-10019 America/Monterrey Mexican Central Time - Coahuila, Durango, Nuevo Leon, Tamaulipas away from US border
|
||||
MX +2550-09730 America/Matamoros US Central Time - Coahuila, Durango, Nuevo Leon, Tamaulipas near US border
|
||||
MX +2313-10625 America/Mazatlan Mountain Time - S Baja, Nayarit, Sinaloa
|
||||
MX +2838-10605 America/Chihuahua Mexican Mountain Time - Chihuahua away from US border
|
||||
MX +2934-10425 America/Ojinaga US Mountain Time - Chihuahua near US border
|
||||
MX +2904-11058 America/Hermosillo Mountain Standard Time - Sonora
|
||||
MX +3232-11701 America/Tijuana US Pacific Time - Baja California near US border
|
||||
MX +3018-11452 America/Santa_Isabel Mexican Pacific Time - Baja California away from US border
|
||||
MX +2048-10515 America/Bahia_Banderas Mexican Central Time - Bahia de Banderas
|
||||
MY +0310+10142 Asia/Kuala_Lumpur peninsular Malaysia
|
||||
MY +0133+11020 Asia/Kuching Sabah & Sarawak
|
||||
MZ -2558+03235 Africa/Maputo
|
||||
NA -2234+01706 Africa/Windhoek
|
||||
NC -2216+16627 Pacific/Noumea
|
||||
NE +1331+00207 Africa/Niamey
|
||||
NF -2903+16758 Pacific/Norfolk
|
||||
NG +0627+00324 Africa/Lagos
|
||||
NI +1209-08617 America/Managua
|
||||
NL +5222+00454 Europe/Amsterdam
|
||||
NO +5955+01045 Europe/Oslo
|
||||
NP +2743+08519 Asia/Kathmandu
|
||||
NR -0031+16655 Pacific/Nauru
|
||||
NU -1901-16955 Pacific/Niue
|
||||
NZ -3652+17446 Pacific/Auckland most locations
|
||||
NZ -4357-17633 Pacific/Chatham Chatham Islands
|
||||
OM +2336+05835 Asia/Muscat
|
||||
PA +0858-07932 America/Panama
|
||||
PE -1203-07703 America/Lima
|
||||
PF -1732-14934 Pacific/Tahiti Society Islands
|
||||
PF -0900-13930 Pacific/Marquesas Marquesas Islands
|
||||
PF -2308-13457 Pacific/Gambier Gambier Islands
|
||||
PG -0930+14710 Pacific/Port_Moresby
|
||||
PH +1435+12100 Asia/Manila
|
||||
PK +2452+06703 Asia/Karachi
|
||||
PL +5215+02100 Europe/Warsaw
|
||||
PM +4703-05620 America/Miquelon
|
||||
PN -2504-13005 Pacific/Pitcairn
|
||||
PR +182806-0660622 America/Puerto_Rico
|
||||
PS +3130+03428 Asia/Gaza Gaza Strip
|
||||
PS +313200+0350542 Asia/Hebron West Bank
|
||||
PT +3843-00908 Europe/Lisbon mainland
|
||||
PT +3238-01654 Atlantic/Madeira Madeira Islands
|
||||
PT +3744-02540 Atlantic/Azores Azores
|
||||
PW +0720+13429 Pacific/Palau
|
||||
PY -2516-05740 America/Asuncion
|
||||
QA +2517+05132 Asia/Qatar
|
||||
RE -2052+05528 Indian/Reunion
|
||||
RO +4426+02606 Europe/Bucharest
|
||||
RS +4450+02030 Europe/Belgrade
|
||||
RU +5443+02030 Europe/Kaliningrad Moscow-01 - Kaliningrad
|
||||
RU +554521+0373704 Europe/Moscow Moscow+00 - west Russia
|
||||
RU +4457+03406 Europe/Simferopol Moscow+00 - Crimea
|
||||
RU +4844+04425 Europe/Volgograd Moscow+00 - Caspian Sea
|
||||
RU +5312+05009 Europe/Samara Moscow+00 (Moscow+01 after 2014-10-26) - Samara, Udmurtia
|
||||
RU +5651+06036 Asia/Yekaterinburg Moscow+02 - Urals
|
||||
RU +5500+07324 Asia/Omsk Moscow+03 - west Siberia
|
||||
RU +5502+08255 Asia/Novosibirsk Moscow+03 - Novosibirsk
|
||||
RU +5345+08707 Asia/Novokuznetsk Moscow+03 (Moscow+04 after 2014-10-26) - Kemerovo
|
||||
RU +5601+09250 Asia/Krasnoyarsk Moscow+04 - Yenisei River
|
||||
RU +5216+10420 Asia/Irkutsk Moscow+05 - Lake Baikal
|
||||
RU +5203+11328 Asia/Chita Moscow+06 (Moscow+05 after 2014-10-26) - Zabaykalsky
|
||||
RU +6200+12940 Asia/Yakutsk Moscow+06 - Lena River
|
||||
RU +623923+1353314 Asia/Khandyga Moscow+06 - Tomponsky, Ust-Maysky
|
||||
RU +4310+13156 Asia/Vladivostok Moscow+07 - Amur River
|
||||
RU +4658+14242 Asia/Sakhalin Moscow+07 - Sakhalin Island
|
||||
RU +643337+1431336 Asia/Ust-Nera Moscow+07 - Oymyakonsky
|
||||
RU +5934+15048 Asia/Magadan Moscow+08 (Moscow+07 after 2014-10-26) - Magadan
|
||||
RU +6728+15343 Asia/Srednekolymsk Moscow+08 - E Sakha, N Kuril Is
|
||||
RU +5301+15839 Asia/Kamchatka Moscow+08 (Moscow+09 after 2014-10-26) - Kamchatka
|
||||
RU +6445+17729 Asia/Anadyr Moscow+08 (Moscow+09 after 2014-10-26) - Bering Sea
|
||||
RW -0157+03004 Africa/Kigali
|
||||
SA +2438+04643 Asia/Riyadh
|
||||
SB -0932+16012 Pacific/Guadalcanal
|
||||
SC -0440+05528 Indian/Mahe
|
||||
SD +1536+03232 Africa/Khartoum
|
||||
SE +5920+01803 Europe/Stockholm
|
||||
SG +0117+10351 Asia/Singapore
|
||||
SH -1555-00542 Atlantic/St_Helena
|
||||
SI +4603+01431 Europe/Ljubljana
|
||||
SJ +7800+01600 Arctic/Longyearbyen
|
||||
SK +4809+01707 Europe/Bratislava
|
||||
SL +0830-01315 Africa/Freetown
|
||||
SM +4355+01228 Europe/San_Marino
|
||||
SN +1440-01726 Africa/Dakar
|
||||
SO +0204+04522 Africa/Mogadishu
|
||||
SR +0550-05510 America/Paramaribo
|
||||
SS +0451+03136 Africa/Juba
|
||||
ST +0020+00644 Africa/Sao_Tome
|
||||
SV +1342-08912 America/El_Salvador
|
||||
SX +180305-0630250 America/Lower_Princes
|
||||
SY +3330+03618 Asia/Damascus
|
||||
SZ -2618+03106 Africa/Mbabane
|
||||
TC +2128-07108 America/Grand_Turk
|
||||
TD +1207+01503 Africa/Ndjamena
|
||||
TF -492110+0701303 Indian/Kerguelen
|
||||
TG +0608+00113 Africa/Lome
|
||||
TH +1345+10031 Asia/Bangkok
|
||||
TJ +3835+06848 Asia/Dushanbe
|
||||
TK -0922-17114 Pacific/Fakaofo
|
||||
TL -0833+12535 Asia/Dili
|
||||
TM +3757+05823 Asia/Ashgabat
|
||||
TN +3648+01011 Africa/Tunis
|
||||
TO -2110-17510 Pacific/Tongatapu
|
||||
TR +4101+02858 Europe/Istanbul
|
||||
TT +1039-06131 America/Port_of_Spain
|
||||
TV -0831+17913 Pacific/Funafuti
|
||||
TW +2503+12130 Asia/Taipei
|
||||
TZ -0648+03917 Africa/Dar_es_Salaam
|
||||
UA +5026+03031 Europe/Kiev most locations
|
||||
UA +4837+02218 Europe/Uzhgorod Ruthenia
|
||||
UA +4750+03510 Europe/Zaporozhye Zaporozh'ye, E Lugansk / Zaporizhia, E Luhansk
|
||||
UG +0019+03225 Africa/Kampala
|
||||
UM +1645-16931 Pacific/Johnston Johnston Atoll
|
||||
UM +2813-17722 Pacific/Midway Midway Islands
|
||||
UM +1917+16637 Pacific/Wake Wake Island
|
||||
US +404251-0740023 America/New_York Eastern Time
|
||||
US +421953-0830245 America/Detroit Eastern Time - Michigan - most locations
|
||||
US +381515-0854534 America/Kentucky/Louisville Eastern Time - Kentucky - Louisville area
|
||||
US +364947-0845057 America/Kentucky/Monticello Eastern Time - Kentucky - Wayne County
|
||||
US +394606-0860929 America/Indiana/Indianapolis Eastern Time - Indiana - most locations
|
||||
US +384038-0873143 America/Indiana/Vincennes Eastern Time - Indiana - Daviess, Dubois, Knox & Martin Counties
|
||||
US +410305-0863611 America/Indiana/Winamac Eastern Time - Indiana - Pulaski County
|
||||
US +382232-0862041 America/Indiana/Marengo Eastern Time - Indiana - Crawford County
|
||||
US +382931-0871643 America/Indiana/Petersburg Eastern Time - Indiana - Pike County
|
||||
US +384452-0850402 America/Indiana/Vevay Eastern Time - Indiana - Switzerland County
|
||||
US +415100-0873900 America/Chicago Central Time
|
||||
US +375711-0864541 America/Indiana/Tell_City Central Time - Indiana - Perry County
|
||||
US +411745-0863730 America/Indiana/Knox Central Time - Indiana - Starke County
|
||||
US +450628-0873651 America/Menominee Central Time - Michigan - Dickinson, Gogebic, Iron & Menominee Counties
|
||||
US +470659-1011757 America/North_Dakota/Center Central Time - North Dakota - Oliver County
|
||||
US +465042-1012439 America/North_Dakota/New_Salem Central Time - North Dakota - Morton County (except Mandan area)
|
||||
US +471551-1014640 America/North_Dakota/Beulah Central Time - North Dakota - Mercer County
|
||||
US +394421-1045903 America/Denver Mountain Time
|
||||
US +433649-1161209 America/Boise Mountain Time - south Idaho & east Oregon
|
||||
US +332654-1120424 America/Phoenix Mountain Standard Time - Arizona (except Navajo)
|
||||
US +340308-1181434 America/Los_Angeles Pacific Time
|
||||
US +550737-1313435 America/Metlakatla Pacific Standard Time - Annette Island, Alaska
|
||||
US +611305-1495401 America/Anchorage Alaska Time
|
||||
US +581807-1342511 America/Juneau Alaska Time - Alaska panhandle
|
||||
US +571035-1351807 America/Sitka Alaska Time - southeast Alaska panhandle
|
||||
US +593249-1394338 America/Yakutat Alaska Time - Alaska panhandle neck
|
||||
US +643004-1652423 America/Nome Alaska Time - west Alaska
|
||||
US +515248-1763929 America/Adak Aleutian Islands
|
||||
US +211825-1575130 Pacific/Honolulu Hawaii
|
||||
UY -3453-05611 America/Montevideo
|
||||
UZ +3940+06648 Asia/Samarkand west Uzbekistan
|
||||
UZ +4120+06918 Asia/Tashkent east Uzbekistan
|
||||
VA +415408+0122711 Europe/Vatican
|
||||
VC +1309-06114 America/St_Vincent
|
||||
VE +1030-06656 America/Caracas
|
||||
VG +1827-06437 America/Tortola
|
||||
VI +1821-06456 America/St_Thomas
|
||||
VN +1045+10640 Asia/Ho_Chi_Minh
|
||||
VU -1740+16825 Pacific/Efate
|
||||
WF -1318-17610 Pacific/Wallis
|
||||
WS -1350-17144 Pacific/Apia
|
||||
YE +1245+04512 Asia/Aden
|
||||
YT -1247+04514 Indian/Mayotte
|
||||
ZA -2615+02800 Africa/Johannesburg
|
||||
ZM -1525+02817 Africa/Lusaka
|
||||
ZW -1750+03103 Africa/Harare
|
|
@ -1,369 +0,0 @@
|
|||
# tz zone descriptions
|
||||
#
|
||||
# This file is in the public domain.
|
||||
#
|
||||
# From Paul Eggert (2014-07-31):
|
||||
# This file contains a table where each row stands for a zone where
|
||||
# civil time stamps have agreed since 1970. Columns are separated by
|
||||
# a single tab. Lines beginning with '#' are comments. All text uses
|
||||
# UTF-8 encoding. The columns of the table are as follows:
|
||||
#
|
||||
# 1. The countries that overlap the zone, as a comma-separated list
|
||||
# of ISO 3166 2-character country codes. See the file 'iso3166.tab'.
|
||||
# 2. Latitude and longitude of the zone's principal location
|
||||
# in ISO 6709 sign-degrees-minutes-seconds format,
|
||||
# either +-DDMM+-DDDMM or +-DDMMSS+-DDDMMSS,
|
||||
# first latitude (+ is north), then longitude (+ is east).
|
||||
# 3. Zone name used in value of TZ environment variable.
|
||||
# Please see the 'Theory' file for how zone names are chosen.
|
||||
# If multiple zones overlap a country, each has a row in the
|
||||
# table, with each column 1 containing the country code.
|
||||
# 4. Comments; present if and only if a country has multiple zones.
|
||||
#
|
||||
# If a zone covers multiple countries, the most-populous city is used,
|
||||
# and that country is listed first in column 1; any other countries
|
||||
# are listed alphabetically by country code. The table is sorted
|
||||
# first by country code, then (if possible) by an order within the
|
||||
# country that (1) makes some geographical sense, and (2) puts the
|
||||
# most populous zones first, where that does not contradict (1).
|
||||
#
|
||||
# This table is intended as an aid for users, to help them select time
|
||||
# zone data appropriate for their practical needs. It is not intended
|
||||
# to take or endorse any position on legal or territorial claims.
|
||||
#
|
||||
#country-
|
||||
#codes coordinates TZ comments
|
||||
AD +4230+00131 Europe/Andorra
|
||||
AE,OM +2518+05518 Asia/Dubai
|
||||
AF +3431+06912 Asia/Kabul
|
||||
AL +4120+01950 Europe/Tirane
|
||||
AM +4011+04430 Asia/Yerevan
|
||||
AQ -6734-06808 Antarctica/Rothera Rothera Station, Adelaide Island
|
||||
AQ -6448-06406 Antarctica/Palmer Palmer Station, Anvers Island
|
||||
AQ -6736+06253 Antarctica/Mawson Mawson Station, Holme Bay
|
||||
AQ -6835+07758 Antarctica/Davis Davis Station, Vestfold Hills
|
||||
AQ -6617+11031 Antarctica/Casey Casey Station, Bailey Peninsula
|
||||
AQ -7824+10654 Antarctica/Vostok Vostok Station, Lake Vostok
|
||||
AQ -6640+14001 Antarctica/DumontDUrville Dumont-d'Urville Station, Terre Adelie
|
||||
AQ -690022+0393524 Antarctica/Syowa Syowa Station, E Ongul I
|
||||
AQ -720041+0023206 Antarctica/Troll Troll Station, Queen Maud Land
|
||||
AR -3436-05827 America/Argentina/Buenos_Aires Buenos Aires (BA, CF)
|
||||
AR -3124-06411 America/Argentina/Cordoba most locations (CB, CC, CN, ER, FM, MN, SE, SF)
|
||||
AR -2447-06525 America/Argentina/Salta (SA, LP, NQ, RN)
|
||||
AR -2411-06518 America/Argentina/Jujuy Jujuy (JY)
|
||||
AR -2649-06513 America/Argentina/Tucuman Tucumán (TM)
|
||||
AR -2828-06547 America/Argentina/Catamarca Catamarca (CT), Chubut (CH)
|
||||
AR -2926-06651 America/Argentina/La_Rioja La Rioja (LR)
|
||||
AR -3132-06831 America/Argentina/San_Juan San Juan (SJ)
|
||||
AR -3253-06849 America/Argentina/Mendoza Mendoza (MZ)
|
||||
AR -3319-06621 America/Argentina/San_Luis San Luis (SL)
|
||||
AR -5138-06913 America/Argentina/Rio_Gallegos Santa Cruz (SC)
|
||||
AR -5448-06818 America/Argentina/Ushuaia Tierra del Fuego (TF)
|
||||
AS,UM -1416-17042 Pacific/Pago_Pago Samoa, Midway
|
||||
AT +4813+01620 Europe/Vienna
|
||||
AU -3133+15905 Australia/Lord_Howe Lord Howe Island
|
||||
AU -5430+15857 Antarctica/Macquarie Macquarie Island
|
||||
AU -4253+14719 Australia/Hobart Tasmania - most locations
|
||||
AU -3956+14352 Australia/Currie Tasmania - King Island
|
||||
AU -3749+14458 Australia/Melbourne Victoria
|
||||
AU -3352+15113 Australia/Sydney New South Wales - most locations
|
||||
AU -3157+14127 Australia/Broken_Hill New South Wales - Yancowinna
|
||||
AU -2728+15302 Australia/Brisbane Queensland - most locations
|
||||
AU -2016+14900 Australia/Lindeman Queensland - Holiday Islands
|
||||
AU -3455+13835 Australia/Adelaide South Australia
|
||||
AU -1228+13050 Australia/Darwin Northern Territory
|
||||
AU -3157+11551 Australia/Perth Western Australia - most locations
|
||||
AU -3143+12852 Australia/Eucla Western Australia - Eucla area
|
||||
AZ +4023+04951 Asia/Baku
|
||||
BB +1306-05937 America/Barbados
|
||||
BD +2343+09025 Asia/Dhaka
|
||||
BE +5050+00420 Europe/Brussels
|
||||
BG +4241+02319 Europe/Sofia
|
||||
BM +3217-06446 Atlantic/Bermuda
|
||||
BN +0456+11455 Asia/Brunei
|
||||
BO -1630-06809 America/La_Paz
|
||||
BR -0351-03225 America/Noronha Atlantic islands
|
||||
BR -0127-04829 America/Belem Amapá, E Pará
|
||||
BR -0343-03830 America/Fortaleza NE Brazil (MA, PI, CE, RN, PB)
|
||||
BR -0803-03454 America/Recife Pernambuco
|
||||
BR -0712-04812 America/Araguaina Tocantins
|
||||
BR -0940-03543 America/Maceio Alagoas, Sergipe
|
||||
BR -1259-03831 America/Bahia Bahia
|
||||
BR -2332-04637 America/Sao_Paulo S & SE Brazil (GO, DF, MG, ES, RJ, SP, PR, SC, RS)
|
||||
BR -2027-05437 America/Campo_Grande Mato Grosso do Sul
|
||||
BR -1535-05605 America/Cuiaba Mato Grosso
|
||||
BR -0226-05452 America/Santarem W Pará
|
||||
BR -0846-06354 America/Porto_Velho Rondônia
|
||||
BR +0249-06040 America/Boa_Vista Roraima
|
||||
BR -0308-06001 America/Manaus E Amazonas
|
||||
BR -0640-06952 America/Eirunepe W Amazonas
|
||||
BR -0958-06748 America/Rio_Branco Acre
|
||||
BS +2505-07721 America/Nassau
|
||||
BT +2728+08939 Asia/Thimphu
|
||||
BY +5354+02734 Europe/Minsk
|
||||
BZ +1730-08812 America/Belize
|
||||
CA +4734-05243 America/St_Johns Newfoundland Time, including SE Labrador
|
||||
CA +4439-06336 America/Halifax Atlantic Time - Nova Scotia (most places), PEI
|
||||
CA +4612-05957 America/Glace_Bay Atlantic Time - Nova Scotia - places that did not observe DST 1966-1971
|
||||
CA +4606-06447 America/Moncton Atlantic Time - New Brunswick
|
||||
CA +5320-06025 America/Goose_Bay Atlantic Time - Labrador - most locations
|
||||
CA +5125-05707 America/Blanc-Sablon Atlantic Standard Time - Quebec - Lower North Shore
|
||||
CA +4339-07923 America/Toronto Eastern Time - Ontario & Quebec - most locations
|
||||
CA +4901-08816 America/Nipigon Eastern Time - Ontario & Quebec - places that did not observe DST 1967-1973
|
||||
CA +4823-08915 America/Thunder_Bay Eastern Time - Thunder Bay, Ontario
|
||||
CA +6344-06828 America/Iqaluit Eastern Time - east Nunavut - most locations
|
||||
CA +6608-06544 America/Pangnirtung Eastern Time - Pangnirtung, Nunavut
|
||||
CA +744144-0944945 America/Resolute Central Time - Resolute, Nunavut
|
||||
CA +484531-0913718 America/Atikokan Eastern Standard Time - Atikokan, Ontario and Southampton I, Nunavut
|
||||
CA +624900-0920459 America/Rankin_Inlet Central Time - central Nunavut
|
||||
CA +4953-09709 America/Winnipeg Central Time - Manitoba & west Ontario
|
||||
CA +4843-09434 America/Rainy_River Central Time - Rainy River & Fort Frances, Ontario
|
||||
CA +5024-10439 America/Regina Central Standard Time - Saskatchewan - most locations
|
||||
CA +5017-10750 America/Swift_Current Central Standard Time - Saskatchewan - midwest
|
||||
CA +5333-11328 America/Edmonton Mountain Time - Alberta, east British Columbia & west Saskatchewan
|
||||
CA +690650-1050310 America/Cambridge_Bay Mountain Time - west Nunavut
|
||||
CA +6227-11421 America/Yellowknife Mountain Time - central Northwest Territories
|
||||
CA +682059-1334300 America/Inuvik Mountain Time - west Northwest Territories
|
||||
CA +4906-11631 America/Creston Mountain Standard Time - Creston, British Columbia
|
||||
CA +5946-12014 America/Dawson_Creek Mountain Standard Time - Dawson Creek & Fort Saint John, British Columbia
|
||||
CA +4916-12307 America/Vancouver Pacific Time - west British Columbia
|
||||
CA +6043-13503 America/Whitehorse Pacific Time - south Yukon
|
||||
CA +6404-13925 America/Dawson Pacific Time - north Yukon
|
||||
CC -1210+09655 Indian/Cocos
|
||||
CH,DE,LI +4723+00832 Europe/Zurich Swiss time
|
||||
CI,BF,GM,GN,ML,MR,SH,SL,SN,ST,TG +0519-00402 Africa/Abidjan
|
||||
CK -2114-15946 Pacific/Rarotonga
|
||||
CL -3327-07040 America/Santiago most locations
|
||||
CL -2709-10926 Pacific/Easter Easter Island
|
||||
CN +3114+12128 Asia/Shanghai Beijing Time
|
||||
CN +4348+08735 Asia/Urumqi Xinjiang Time
|
||||
CO +0436-07405 America/Bogota
|
||||
CR +0956-08405 America/Costa_Rica
|
||||
CU +2308-08222 America/Havana
|
||||
CV +1455-02331 Atlantic/Cape_Verde
|
||||
CW,AW,BQ,SX +1211-06900 America/Curacao
|
||||
CX -1025+10543 Indian/Christmas
|
||||
CY +3510+03322 Asia/Nicosia
|
||||
CZ,SK +5005+01426 Europe/Prague
|
||||
DE +5230+01322 Europe/Berlin Berlin time
|
||||
DK +5540+01235 Europe/Copenhagen
|
||||
DO +1828-06954 America/Santo_Domingo
|
||||
DZ +3647+00303 Africa/Algiers
|
||||
EC -0210-07950 America/Guayaquil mainland
|
||||
EC -0054-08936 Pacific/Galapagos Galápagos Islands
|
||||
EE +5925+02445 Europe/Tallinn
|
||||
EG +3003+03115 Africa/Cairo
|
||||
EH +2709-01312 Africa/El_Aaiun
|
||||
ES +4024-00341 Europe/Madrid mainland
|
||||
ES +3553-00519 Africa/Ceuta Ceuta & Melilla
|
||||
ES +2806-01524 Atlantic/Canary Canary Islands
|
||||
FI,AX +6010+02458 Europe/Helsinki
|
||||
FJ -1808+17825 Pacific/Fiji
|
||||
FK -5142-05751 Atlantic/Stanley
|
||||
FM +0725+15147 Pacific/Chuuk Chuuk (Truk) and Yap
|
||||
FM +0658+15813 Pacific/Pohnpei Pohnpei (Ponape)
|
||||
FM +0519+16259 Pacific/Kosrae Kosrae
|
||||
FO +6201-00646 Atlantic/Faroe
|
||||
FR +4852+00220 Europe/Paris
|
||||
GB,GG,IM,JE +513030-0000731 Europe/London
|
||||
GE +4143+04449 Asia/Tbilisi
|
||||
GF +0456-05220 America/Cayenne
|
||||
GH +0533-00013 Africa/Accra
|
||||
GI +3608-00521 Europe/Gibraltar
|
||||
GL +6411-05144 America/Godthab most locations
|
||||
GL +7646-01840 America/Danmarkshavn east coast, north of Scoresbysund
|
||||
GL +7029-02158 America/Scoresbysund Scoresbysund / Ittoqqortoormiit
|
||||
GL +7634-06847 America/Thule Thule / Pituffik
|
||||
GR +3758+02343 Europe/Athens
|
||||
GS -5416-03632 Atlantic/South_Georgia
|
||||
GT +1438-09031 America/Guatemala
|
||||
GU,MP +1328+14445 Pacific/Guam
|
||||
GW +1151-01535 Africa/Bissau
|
||||
GY +0648-05810 America/Guyana
|
||||
HK +2217+11409 Asia/Hong_Kong
|
||||
HN +1406-08713 America/Tegucigalpa
|
||||
HT +1832-07220 America/Port-au-Prince
|
||||
HU +4730+01905 Europe/Budapest
|
||||
ID -0610+10648 Asia/Jakarta Java & Sumatra
|
||||
ID -0002+10920 Asia/Pontianak west & central Borneo
|
||||
ID -0507+11924 Asia/Makassar east & south Borneo, Sulawesi (Celebes), Bali, Nusa Tengarra, west Timor
|
||||
ID -0232+14042 Asia/Jayapura west New Guinea (Irian Jaya) & Malukus (Moluccas)
|
||||
IE +5320-00615 Europe/Dublin
|
||||
IL +314650+0351326 Asia/Jerusalem
|
||||
IN +2232+08822 Asia/Kolkata
|
||||
IO -0720+07225 Indian/Chagos
|
||||
IQ +3321+04425 Asia/Baghdad
|
||||
IR +3540+05126 Asia/Tehran
|
||||
IS +6409-02151 Atlantic/Reykjavik
|
||||
IT,SM,VA +4154+01229 Europe/Rome
|
||||
JM +175805-0764736 America/Jamaica
|
||||
JO +3157+03556 Asia/Amman
|
||||
JP +353916+1394441 Asia/Tokyo
|
||||
KE,DJ,ER,ET,KM,MG,SO,TZ,UG,YT -0117+03649 Africa/Nairobi
|
||||
KG +4254+07436 Asia/Bishkek
|
||||
KI +0125+17300 Pacific/Tarawa Gilbert Islands
|
||||
KI -0308-17105 Pacific/Enderbury Phoenix Islands
|
||||
KI +0152-15720 Pacific/Kiritimati Line Islands
|
||||
KP +3901+12545 Asia/Pyongyang
|
||||
KR +3733+12658 Asia/Seoul
|
||||
KZ +4315+07657 Asia/Almaty most locations
|
||||
KZ +4448+06528 Asia/Qyzylorda Qyzylorda (Kyzylorda, Kzyl-Orda)
|
||||
KZ +5017+05710 Asia/Aqtobe Aqtobe (Aktobe)
|
||||
KZ +4431+05016 Asia/Aqtau Atyrau (Atirau, Gur'yev), Mangghystau (Mankistau)
|
||||
KZ +5113+05121 Asia/Oral West Kazakhstan
|
||||
LB +3353+03530 Asia/Beirut
|
||||
LK +0656+07951 Asia/Colombo
|
||||
LR +0618-01047 Africa/Monrovia
|
||||
LT +5441+02519 Europe/Vilnius
|
||||
LU +4936+00609 Europe/Luxembourg
|
||||
LV +5657+02406 Europe/Riga
|
||||
LY +3254+01311 Africa/Tripoli
|
||||
MA +3339-00735 Africa/Casablanca
|
||||
MC +4342+00723 Europe/Monaco
|
||||
MD +4700+02850 Europe/Chisinau
|
||||
MH +0709+17112 Pacific/Majuro most locations
|
||||
MH +0905+16720 Pacific/Kwajalein Kwajalein
|
||||
MM +1647+09610 Asia/Rangoon
|
||||
MN +4755+10653 Asia/Ulaanbaatar most locations
|
||||
MN +4801+09139 Asia/Hovd Bayan-Ölgii, Govi-Altai, Hovd, Uvs, Zavkhan
|
||||
MN +4804+11430 Asia/Choibalsan Dornod, Sükhbaatar
|
||||
MO +2214+11335 Asia/Macau
|
||||
MQ +1436-06105 America/Martinique
|
||||
MT +3554+01431 Europe/Malta
|
||||
MU -2010+05730 Indian/Mauritius
|
||||
MV +0410+07330 Indian/Maldives
|
||||
MX +1924-09909 America/Mexico_City Central Time - most locations
|
||||
MX +2105-08646 America/Cancun Central Time - Quintana Roo
|
||||
MX +2058-08937 America/Merida Central Time - Campeche, Yucatán
|
||||
MX +2540-10019 America/Monterrey Mexican Central Time - Coahuila, Durango, Nuevo León, Tamaulipas away from US border
|
||||
MX +2550-09730 America/Matamoros US Central Time - Coahuila, Durango, Nuevo León, Tamaulipas near US border
|
||||
MX +2313-10625 America/Mazatlan Mountain Time - S Baja, Nayarit, Sinaloa
|
||||
MX +2838-10605 America/Chihuahua Mexican Mountain Time - Chihuahua away from US border
|
||||
MX +2934-10425 America/Ojinaga US Mountain Time - Chihuahua near US border
|
||||
MX +2904-11058 America/Hermosillo Mountain Standard Time - Sonora
|
||||
MX +3232-11701 America/Tijuana US Pacific Time - Baja California near US border
|
||||
MX +3018-11452 America/Santa_Isabel Mexican Pacific Time - Baja California away from US border
|
||||
MX +2048-10515 America/Bahia_Banderas Mexican Central Time - Bahía de Banderas
|
||||
MY +0310+10142 Asia/Kuala_Lumpur peninsular Malaysia
|
||||
MY +0133+11020 Asia/Kuching Sabah & Sarawak
|
||||
MZ,BI,BW,CD,MW,RW,ZM,ZW -2558+03235 Africa/Maputo Central Africa Time (UTC+2)
|
||||
NA -2234+01706 Africa/Windhoek
|
||||
NC -2216+16627 Pacific/Noumea
|
||||
NF -2903+16758 Pacific/Norfolk
|
||||
NG,AO,BJ,CD,CF,CG,CM,GA,GQ,NE +0627+00324 Africa/Lagos West Africa Time (UTC+1)
|
||||
NI +1209-08617 America/Managua
|
||||
NL +5222+00454 Europe/Amsterdam
|
||||
NO,SJ +5955+01045 Europe/Oslo
|
||||
NP +2743+08519 Asia/Kathmandu
|
||||
NR -0031+16655 Pacific/Nauru
|
||||
NU -1901-16955 Pacific/Niue
|
||||
NZ,AQ -3652+17446 Pacific/Auckland New Zealand time
|
||||
NZ -4357-17633 Pacific/Chatham Chatham Islands
|
||||
PA,KY +0858-07932 America/Panama
|
||||
PE -1203-07703 America/Lima
|
||||
PF -1732-14934 Pacific/Tahiti Society Islands
|
||||
PF -0900-13930 Pacific/Marquesas Marquesas Islands
|
||||
PF -2308-13457 Pacific/Gambier Gambier Islands
|
||||
PG -0930+14710 Pacific/Port_Moresby
|
||||
PH +1435+12100 Asia/Manila
|
||||
PK +2452+06703 Asia/Karachi
|
||||
PL +5215+02100 Europe/Warsaw
|
||||
PM +4703-05620 America/Miquelon
|
||||
PN -2504-13005 Pacific/Pitcairn
|
||||
PR +182806-0660622 America/Puerto_Rico
|
||||
PS +3130+03428 Asia/Gaza Gaza Strip
|
||||
PS +313200+0350542 Asia/Hebron West Bank
|
||||
PT +3843-00908 Europe/Lisbon mainland
|
||||
PT +3238-01654 Atlantic/Madeira Madeira Islands
|
||||
PT +3744-02540 Atlantic/Azores Azores
|
||||
PW +0720+13429 Pacific/Palau
|
||||
PY -2516-05740 America/Asuncion
|
||||
QA,BH +2517+05132 Asia/Qatar
|
||||
RE,TF -2052+05528 Indian/Reunion Réunion, Crozet Is, Scattered Is
|
||||
RO +4426+02606 Europe/Bucharest
|
||||
RS,BA,HR,ME,MK,SI +4450+02030 Europe/Belgrade
|
||||
RU +5443+02030 Europe/Kaliningrad Moscow-01 - Kaliningrad
|
||||
RU +554521+0373704 Europe/Moscow Moscow+00 - west Russia
|
||||
RU +4457+03406 Europe/Simferopol Moscow+00 - Crimea
|
||||
RU +4844+04425 Europe/Volgograd Moscow+00 - Caspian Sea
|
||||
RU +5312+05009 Europe/Samara Moscow+00 (Moscow+01 after 2014-10-26) - Samara, Udmurtia
|
||||
RU +5651+06036 Asia/Yekaterinburg Moscow+02 - Urals
|
||||
RU +5500+07324 Asia/Omsk Moscow+03 - west Siberia
|
||||
RU +5502+08255 Asia/Novosibirsk Moscow+03 - Novosibirsk
|
||||
RU +5345+08707 Asia/Novokuznetsk Moscow+03 (Moscow+04 after 2014-10-26) - Kemerovo
|
||||
RU +5601+09250 Asia/Krasnoyarsk Moscow+04 - Yenisei River
|
||||
RU +5216+10420 Asia/Irkutsk Moscow+05 - Lake Baikal
|
||||
RU +5203+11328 Asia/Chita Moscow+06 (Moscow+05 after 2014-10-26) - Zabaykalsky
|
||||
RU +6200+12940 Asia/Yakutsk Moscow+06 - Lena River
|
||||
RU +623923+1353314 Asia/Khandyga Moscow+06 - Tomponsky, Ust-Maysky
|
||||
RU +4310+13156 Asia/Vladivostok Moscow+07 - Amur River
|
||||
RU +4658+14242 Asia/Sakhalin Moscow+07 - Sakhalin Island
|
||||
RU +643337+1431336 Asia/Ust-Nera Moscow+07 - Oymyakonsky
|
||||
RU +5934+15048 Asia/Magadan Moscow+08 (Moscow+07 after 2014-10-26) - Magadan
|
||||
RU +6728+15343 Asia/Srednekolymsk Moscow+08 - E Sakha, N Kuril Is
|
||||
RU +5301+15839 Asia/Kamchatka Moscow+08 (Moscow+09 after 2014-10-26) - Kamchatka
|
||||
RU +6445+17729 Asia/Anadyr Moscow+08 (Moscow+09 after 2014-10-26) - Bering Sea
|
||||
SA,KW,YE +2438+04643 Asia/Riyadh
|
||||
SB -0932+16012 Pacific/Guadalcanal
|
||||
SC -0440+05528 Indian/Mahe
|
||||
SD,SS +1536+03232 Africa/Khartoum
|
||||
SE +5920+01803 Europe/Stockholm
|
||||
SG +0117+10351 Asia/Singapore
|
||||
SR +0550-05510 America/Paramaribo
|
||||
SV +1342-08912 America/El_Salvador
|
||||
SY +3330+03618 Asia/Damascus
|
||||
TC +2128-07108 America/Grand_Turk
|
||||
TD +1207+01503 Africa/Ndjamena
|
||||
TF -492110+0701303 Indian/Kerguelen Kerguelen, St Paul I, Amsterdam I
|
||||
TH,KH,LA,VN +1345+10031 Asia/Bangkok
|
||||
TJ +3835+06848 Asia/Dushanbe
|
||||
TK -0922-17114 Pacific/Fakaofo
|
||||
TL -0833+12535 Asia/Dili
|
||||
TM +3757+05823 Asia/Ashgabat
|
||||
TN +3648+01011 Africa/Tunis
|
||||
TO -2110-17510 Pacific/Tongatapu
|
||||
TR +4101+02858 Europe/Istanbul
|
||||
TT,AG,AI,BL,DM,GD,GP,MF,LC,KN,MS,VC,VG,VI +1039-06131 America/Port_of_Spain
|
||||
TV -0831+17913 Pacific/Funafuti
|
||||
TW +2503+12130 Asia/Taipei
|
||||
UA +5026+03031 Europe/Kiev most locations
|
||||
UA +4837+02218 Europe/Uzhgorod Ruthenia
|
||||
UA +4750+03510 Europe/Zaporozhye Zaporozh'ye, E Lugansk / Zaporizhia, E Luhansk
|
||||
UM +1917+16637 Pacific/Wake Wake Island
|
||||
US +404251-0740023 America/New_York Eastern Time
|
||||
US +421953-0830245 America/Detroit Eastern Time - Michigan - most locations
|
||||
US +381515-0854534 America/Kentucky/Louisville Eastern Time - Kentucky - Louisville area
|
||||
US +364947-0845057 America/Kentucky/Monticello Eastern Time - Kentucky - Wayne County
|
||||
US +394606-0860929 America/Indiana/Indianapolis Eastern Time - Indiana - most locations
|
||||
US +384038-0873143 America/Indiana/Vincennes Eastern Time - Indiana - Daviess, Dubois, Knox & Martin Counties
|
||||
US +410305-0863611 America/Indiana/Winamac Eastern Time - Indiana - Pulaski County
|
||||
US +382232-0862041 America/Indiana/Marengo Eastern Time - Indiana - Crawford County
|
||||
US +382931-0871643 America/Indiana/Petersburg Eastern Time - Indiana - Pike County
|
||||
US +384452-0850402 America/Indiana/Vevay Eastern Time - Indiana - Switzerland County
|
||||
US +415100-0873900 America/Chicago Central Time
|
||||
US +375711-0864541 America/Indiana/Tell_City Central Time - Indiana - Perry County
|
||||
US +411745-0863730 America/Indiana/Knox Central Time - Indiana - Starke County
|
||||
US +450628-0873651 America/Menominee Central Time - Michigan - Dickinson, Gogebic, Iron & Menominee Counties
|
||||
US +470659-1011757 America/North_Dakota/Center Central Time - North Dakota - Oliver County
|
||||
US +465042-1012439 America/North_Dakota/New_Salem Central Time - North Dakota - Morton County (except Mandan area)
|
||||
US +471551-1014640 America/North_Dakota/Beulah Central Time - North Dakota - Mercer County
|
||||
US +394421-1045903 America/Denver Mountain Time
|
||||
US +433649-1161209 America/Boise Mountain Time - south Idaho & east Oregon
|
||||
US +332654-1120424 America/Phoenix Mountain Standard Time - Arizona (except Navajo)
|
||||
US +340308-1181434 America/Los_Angeles Pacific Time
|
||||
US +550737-1313435 America/Metlakatla Pacific Standard Time - Annette Island, Alaska
|
||||
US +611305-1495401 America/Anchorage Alaska Time
|
||||
US +581807-1342511 America/Juneau Alaska Time - Alaska panhandle
|
||||
US +571035-1351807 America/Sitka Alaska Time - southeast Alaska panhandle
|
||||
US +593249-1394338 America/Yakutat Alaska Time - Alaska panhandle neck
|
||||
US +643004-1652423 America/Nome Alaska Time - west Alaska
|
||||
US +515248-1763929 America/Adak Aleutian Islands
|
||||
US,UM +211825-1575130 Pacific/Honolulu Hawaii time
|
||||
UY -3453-05611 America/Montevideo
|
||||
UZ +3940+06648 Asia/Samarkand west Uzbekistan
|
||||
UZ +4120+06918 Asia/Tashkent east Uzbekistan
|
||||
VE +1030-06656 America/Caracas
|
||||
VU -1740+16825 Pacific/Efate
|
||||
WF -1318-17610 Pacific/Wallis
|
||||
WS -1350-17144 Pacific/Apia
|
||||
ZA,LS,SZ -2615+02800 Africa/Johannesburg
|
|
@ -1,64 +0,0 @@
|
|||
#lang racket/base
|
||||
|
||||
(require racket/date
|
||||
racket/runtime-path
|
||||
rackunit)
|
||||
(require "../main.rkt"
|
||||
"../zoneinfo.rkt")
|
||||
|
||||
(define-runtime-path TEST64-DIR "data/64-bit")
|
||||
(define-runtime-path TEST32-DIR "data/32-bit")
|
||||
|
||||
(define IN-DST 1409606993)
|
||||
(define GAP-START (find-seconds 0 0 2 9 3 2014 #f))
|
||||
(define OVERLAP-START (find-seconds 0 0 1 2 11 2014 #f))
|
||||
|
||||
(parameterize* ([current-zoneinfo-search-path (list "/path/to/nowhere"
|
||||
TEST64-DIR)]
|
||||
[current-tzinfo-source (make-zoneinfo-source)])
|
||||
|
||||
;; LMT data for this zone is only available in the 64-bit files
|
||||
(check-equal? (utc-seconds->tzoffset "US/Eastern" -999999999999999)
|
||||
(tzoffset -17762 #f "LMT"))
|
||||
|
||||
(check-equal? (utc-seconds->tzoffset "US/Eastern" IN-DST)
|
||||
(tzoffset -14400 #t "EDT"))
|
||||
|
||||
(check-equal? (local-seconds->tzoffset "US/Eastern" IN-DST)
|
||||
(tzoffset -14400 #t "EDT"))
|
||||
|
||||
(check-equal? (local-seconds->tzoffset "US/Eastern" GAP-START)
|
||||
(tzgap (+ GAP-START 18000)
|
||||
(tzoffset -18000 #f "EST")
|
||||
(tzoffset -14400 #t "EDT")))
|
||||
|
||||
(check-equal? (local-seconds->tzoffset "US/Eastern" (sub1 GAP-START))
|
||||
(tzoffset -18000 #f "EST"))
|
||||
|
||||
(check-equal? (local-seconds->tzoffset "US/Eastern" OVERLAP-START)
|
||||
(tzoverlap (tzoffset -14400 #t "EDT")
|
||||
(tzoffset -18000 #f "EST")))
|
||||
|
||||
(check-equal? (local-seconds->tzoffset "US/Eastern" (sub1 OVERLAP-START))
|
||||
(tzoffset -14400 #t "EDT"))
|
||||
|
||||
(check-equal? (local-seconds->tzoffset "US/Eastern" (+ OVERLAP-START 3600))
|
||||
(tzoffset -18000 #f "EST"))
|
||||
|
||||
(check-equal? (local-seconds->tzoffset "US/Eastern" (sub1 (+ OVERLAP-START 3600)))
|
||||
(tzoverlap (tzoffset -14400 #t "EDT")
|
||||
(tzoffset -18000 #f "EST"))))
|
||||
|
||||
(parameterize* ([current-zoneinfo-search-path (list "/path/to/nowhere"
|
||||
TEST32-DIR)]
|
||||
[current-tzinfo-source (make-zoneinfo-source)])
|
||||
;; LMT data for this zone is only available in the 64-bit files
|
||||
(check-equal? (utc-seconds->tzoffset "US/Eastern" -999999999999999)
|
||||
(tzoffset -18000 #f "EST"))
|
||||
|
||||
(check-equal? (utc-seconds->tzoffset "UTC" 238635325)
|
||||
(tzoffset 0 #f "UTC"))
|
||||
|
||||
(check-exn exn:fail:tzinfo:zone-not-found?
|
||||
(λ ()
|
||||
(utc-seconds->tzoffset "Fillory/Whitespire" 675765756))))
|
|
@ -1,9 +0,0 @@
|
|||
#lang racket/base
|
||||
|
||||
(require racket/contract/base)
|
||||
(require "private/generics.rkt"
|
||||
"private/zoneinfo.rkt")
|
||||
|
||||
(provide/contract
|
||||
[current-zoneinfo-search-path (parameter/c (listof path-string?))]
|
||||
[make-zoneinfo-source (-> tzinfo-source?)])
|
|
@ -1,79 +0,0 @@
|
|||
#lang typed/racket/base
|
||||
(require trivial/no-colon)
|
||||
|
||||
;; Front-end:
|
||||
;; Working with current clock
|
||||
|
||||
(provide;/contract
|
||||
current-clock ;any/c]
|
||||
current-posix-seconds ;any/c]
|
||||
now/moment ;(->i () (#:tz [tz tz/c]) [res moment?])]
|
||||
now ;(->i () (#:tz [tz tz/c]) [res datetime?])]
|
||||
today ;(->i () (#:tz [tz tz/c]) [res date?])]
|
||||
current-time ;(->i () (#:tz [tz tz/c]) [res time?])]
|
||||
now/moment/utc ;(-> moment?)]
|
||||
now/utc ;(-> datetime?)]
|
||||
today/utc ;(-> date?)]
|
||||
current-time/utc ;(-> time?)])
|
||||
)
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
|
||||
(require
|
||||
(only-in racket/math exact-round)
|
||||
"../base/types.rkt"
|
||||
"tzinfo-adapter.rkt"
|
||||
"gregor-adapter.rkt"
|
||||
)
|
||||
(require "moment.rkt"
|
||||
)
|
||||
(require "datetime.rkt"
|
||||
)
|
||||
|
||||
;; =============================================================================
|
||||
|
||||
(: now/moment (->* () (#:tz (U tz #f)) Moment))
|
||||
(define (now/moment #:tz [tz (current-timezone)])
|
||||
(unless tz (error "current-timezone is #f"))
|
||||
(posix->moment ((current-clock)) tz))
|
||||
|
||||
(: now/moment/utc (-> Moment))
|
||||
(define (now/moment/utc)
|
||||
(now/moment #:tz "Etc/UTC"))
|
||||
|
||||
(: now (->* () (#:tz (U tz #f)) DateTime))
|
||||
(define (now #:tz [tz (current-timezone)])
|
||||
(unless tz (error "now: current-timezone is #f"))
|
||||
(moment->datetime/local (now/moment #:tz tz)))
|
||||
|
||||
(: now/utc (-> DateTime))
|
||||
(define (now/utc)
|
||||
(now #:tz "Etc/UTC"))
|
||||
|
||||
(: today (->* () (#:tz (U tz #f)) Date))
|
||||
(define (today #:tz [tz (current-timezone)])
|
||||
(unless tz (error "today: current-timezone is #f"))
|
||||
(datetime->date (now #:tz tz)))
|
||||
|
||||
(: today/utc (-> Date))
|
||||
(define (today/utc)
|
||||
(today #:tz "Etc/UTC"))
|
||||
|
||||
(: current-time (->* () (#:tz (U tz #f)) Time))
|
||||
(define (current-time #:tz [tz (current-timezone)])
|
||||
(unless tz (error "current-time: current-timezone is #f"))
|
||||
(datetime->time (now #:tz tz)))
|
||||
|
||||
(: current-time/utc (-> Time))
|
||||
(define (current-time/utc)
|
||||
(current-time #:tz "Etc/UTC"))
|
||||
|
||||
(: current-posix-seconds (-> Natural))
|
||||
(define (current-posix-seconds)
|
||||
(let ([r (exact-round (/ (inexact->exact (current-inexact-milliseconds)) 1000))])
|
||||
(unless (index? r) (error "current-posix-seconds"))
|
||||
r))
|
||||
|
||||
(: current-clock (Parameterof (-> Exact-Rational)))
|
||||
(define current-clock (make-parameter current-posix-seconds))
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
#lang typed/racket/base
|
||||
(require trivial/no-colon)
|
||||
|
||||
;; Adapter for gregor's `structs.rkt` file.
|
||||
|
||||
(provide
|
||||
(struct-out YMD)
|
||||
(struct-out HMSN)
|
||||
Month)
|
||||
|
||||
(require
|
||||
"../base/types.rkt")
|
||||
|
||||
(require "core-structs.rkt"
|
||||
)
|
|
@ -1,23 +0,0 @@
|
|||
#lang typed/racket/base
|
||||
(require trivial/no-colon)
|
||||
|
||||
;; Core:
|
||||
;; Essential structs
|
||||
|
||||
(provide
|
||||
(struct-out YMD)
|
||||
(struct-out HMSN)
|
||||
)
|
||||
|
||||
(require "../base/types.rkt")
|
||||
|
||||
;; TODO precise types for year, day, hour, second?
|
||||
;; (the others are not feasible)
|
||||
|
||||
(struct YMD ([y : Natural]
|
||||
[m : Month]
|
||||
[d : Natural]) #:transparent)
|
||||
(struct HMSN ([h : Integer]
|
||||
[m : Integer]
|
||||
[s : Integer]
|
||||
[n : Integer]) #:transparent)
|
|
@ -1,129 +0,0 @@
|
|||
#lang typed/racket/base
|
||||
(require trivial/no-colon)
|
||||
|
||||
;; Working with dates
|
||||
|
||||
(provide;/contract
|
||||
date ;(->i ([year exact-integer?])
|
||||
; ([month (integer-in 1 12)]
|
||||
; [day (year month) (day-of-month/c year month)])
|
||||
; [d date?])]
|
||||
date->ymd ;(-> date? YMD?)]
|
||||
date->jdn ;(-> date? exact-integer?)]
|
||||
ymd->date ;(-> YMD? date?)]
|
||||
jdn->date ;(-> exact-integer? date?)]
|
||||
date->iso-week ;(-> date? (integer-in 1 53))]
|
||||
date->iso-wyear ;(-> date? exact-integer?)]
|
||||
date->iso8601 ;(-> date? string?)]
|
||||
date=? ;(-> date? date? boolean?)]
|
||||
date<=? ;(-> date? date? boolean?)]
|
||||
)
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
|
||||
(require
|
||||
(only-in racket/math exact-round)
|
||||
(only-in racket/format ~r)
|
||||
"core-adapter.rkt"
|
||||
"gregor-adapter.rkt"
|
||||
racket/match)
|
||||
|
||||
(require
|
||||
"ymd.rkt"
|
||||
)
|
||||
|
||||
;; =============================================================================
|
||||
|
||||
(: date-equal-proc (-> Date Date Boolean))
|
||||
(define (date-equal-proc x y)
|
||||
(= (Date-jdn x) (Date-jdn y)))
|
||||
|
||||
(: date-hash-proc (-> Date (-> Integer Integer) Integer))
|
||||
(define (date-hash-proc x fn)
|
||||
(fn (Date-jdn x)))
|
||||
|
||||
(: date-write-proc (-> Date Output-Port Any Void))
|
||||
(define (date-write-proc d out mode)
|
||||
(fprintf out "#<date ~a>" (date->iso8601 d)))
|
||||
|
||||
;; #:methods gen:equal+hash
|
||||
;; [(define equal-proc date-equal-proc)
|
||||
;; (define hash-proc date-hash-proc)
|
||||
;; (define hash2-proc date-hash-proc)]
|
||||
|
||||
;; #:methods gen:custom-write
|
||||
;; [(define write-proc date-write-proc)]
|
||||
|
||||
;; #:property prop:serializable
|
||||
;; (make-serialize-info (λ (d) (vector (date->jdn d)))
|
||||
;; #'deserialize-info:Date
|
||||
;; #f
|
||||
;; (or (current-load-relative-directory)
|
||||
;; (current-directory))))
|
||||
|
||||
(: date? (-> Any Boolean))
|
||||
(define date? Date?)
|
||||
|
||||
(: date (->* (Natural) (Month Natural) Date))
|
||||
(define (date y [m 1] [d 1])
|
||||
(: ymd YMD)
|
||||
(define ymd (YMD y m d))
|
||||
(Date ymd (ymd->jdn ymd)))
|
||||
|
||||
(: date->ymd (-> Date YMD))
|
||||
(define date->ymd Date-ymd)
|
||||
(: date->jdn (-> Date Integer))
|
||||
(define (date->jdn d)
|
||||
(Date-jdn d))
|
||||
|
||||
(: ymd->date (-> YMD Date))
|
||||
(define (ymd->date ymd)
|
||||
(match-define (YMD y m d) ymd)
|
||||
(date y m d))
|
||||
|
||||
(: jdn->date (-> Exact-Rational Date))
|
||||
(define (jdn->date jdn)
|
||||
(Date (jdn->ymd jdn) (exact-round jdn)))
|
||||
|
||||
(: date->iso-week (-> Date Natural))
|
||||
(define (date->iso-week d)
|
||||
(car (date->iso-week+wyear d)))
|
||||
|
||||
(: date->iso-wyear (-> Date Natural))
|
||||
(define (date->iso-wyear d)
|
||||
(cdr (date->iso-week+wyear d)))
|
||||
|
||||
(: date->iso-week+wyear (-> Date (Pairof Natural Natural)))
|
||||
(define (date->iso-week+wyear d)
|
||||
(define ymd (date->ymd d))
|
||||
(define yday (ymd->yday ymd))
|
||||
(define iso-wday (jdn->iso-wday (date->jdn d)))
|
||||
(match-define (YMD y _ _) ymd)
|
||||
(define w (quotient (+ yday (- iso-wday ) 10)
|
||||
7))
|
||||
(cond [(zero? w)
|
||||
(define y-1
|
||||
(let ([r (sub1 y)]) (unless (index? r) (error "date->iso-week+year")) r))
|
||||
(cons (iso-weeks-in-year y-1) y-1)]
|
||||
[(and (= w 53) (> w (iso-weeks-in-year y)))
|
||||
(cons 1 (add1 y))]
|
||||
[(index? w)
|
||||
(cons w y)]
|
||||
[else (error "date->iso-week+year")]))
|
||||
|
||||
(: date->iso8601 (-> Date String))
|
||||
(define (date->iso8601 d)
|
||||
(: f (-> Integer Natural String))
|
||||
(define (f n len) (~r n #:min-width len #:pad-string "0"))
|
||||
|
||||
(match (Date-ymd d)
|
||||
[(YMD y m d) (format "~a-~a-~a" (f y 4) (f m 2) (f d 2))]))
|
||||
|
||||
(: date=? (-> Date Date Boolean))
|
||||
(define (date=? d1 d2)
|
||||
(= (date->jdn d1) (date->jdn d2)))
|
||||
|
||||
(: date<=? (-> Date Date Boolean))
|
||||
(define (date<=? d1 d2)
|
||||
(<= (date->jdn d1) (date->jdn d2)))
|
||||
|
|
@ -1,166 +0,0 @@
|
|||
#lang typed/racket/base
|
||||
(require trivial/no-colon)
|
||||
|
||||
;; Working with DateTime objects
|
||||
;; (i.e. dates and times at the same time)
|
||||
|
||||
(require
|
||||
"core-adapter.rkt"
|
||||
"gregor-adapter.rkt"
|
||||
racket/match
|
||||
(only-in racket/math exact-round exact-floor))
|
||||
|
||||
(require
|
||||
"hmsn.rkt"
|
||||
)
|
||||
(require
|
||||
"date.rkt"
|
||||
)
|
||||
(require "time.rkt"
|
||||
)
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
|
||||
(provide;/contract
|
||||
datetime ;(->i ([year exact-integer?])
|
||||
; ([month (integer-in 1 12)]
|
||||
; [day (year month) (day-of-month/c year month)]
|
||||
; [hour (integer-in 0 23)]
|
||||
; [minute (integer-in 0 59)]
|
||||
; [second (integer-in 0 59)]
|
||||
; [nanosecond (integer-in 0 (sub1 NS/SECOND))])
|
||||
; [dt datetime?])]
|
||||
datetime->date ;(-> datetime? date?)]
|
||||
datetime->time ;(-> datetime? time?)]
|
||||
datetime->jd ;(-> datetime? rational?)]
|
||||
datetime->posix ;(-> datetime? rational?)]
|
||||
date+time->datetime ;(-> date? time? datetime?)]
|
||||
jd->datetime ;(-> real? datetime?)]
|
||||
posix->datetime ;(-> real? datetime?)]
|
||||
datetime->iso8601 ;(-> datetime? string?)]
|
||||
datetime-add-nanoseconds ;(-> datetime? exact-integer? datetime?)]
|
||||
datetime-add-seconds ;(-> datetime? exact-integer? datetime?)]
|
||||
datetime=? ;(-> datetime? datetime? boolean?)]
|
||||
datetime<? ;(-> datetime? datetime? boolean?)]
|
||||
datetime<=? ;(-> datetime? datetime? boolean?)]
|
||||
)
|
||||
|
||||
;; =============================================================================
|
||||
|
||||
(: datetime-equal-proc (-> DateTime DateTime Boolean))
|
||||
(define (datetime-equal-proc x y)
|
||||
(= (datetime->jd x)
|
||||
(datetime->jd y)))
|
||||
|
||||
(: datetime-hash-proc (-> DateTime (-> Exact-Rational Integer) Integer))
|
||||
(define (datetime-hash-proc x fn)
|
||||
(fn (datetime->jd x)))
|
||||
|
||||
(: datetime-write-proc (-> DateTime Output-Port Any Void))
|
||||
(define (datetime-write-proc dt out mode)
|
||||
(fprintf out "#<datetime ~a>" (datetime->iso8601 dt)))
|
||||
|
||||
(: datetime? (-> Any Boolean))
|
||||
(define datetime? DateTime?)
|
||||
|
||||
(: datetime->date (-> DateTime Date))
|
||||
(define datetime->date DateTime-date)
|
||||
(: datetime->time (-> DateTime Time))
|
||||
(define datetime->time DateTime-time)
|
||||
(: datetime->jd (-> DateTime Exact-Rational))
|
||||
(define (datetime->jd d)
|
||||
(DateTime-jd d))
|
||||
|
||||
(: datetime->posix (-> DateTime Exact-Rational))
|
||||
(define (datetime->posix dt)
|
||||
(jd->posix (datetime->jd dt)))
|
||||
|
||||
(: posix->datetime (-> Exact-Rational DateTime))
|
||||
(define (posix->datetime posix)
|
||||
(jd->datetime (posix->jd (inexact->exact posix))))
|
||||
|
||||
(: date+time->datetime (-> Date Time DateTime))
|
||||
(define (date+time->datetime d t)
|
||||
(DateTime d t (date+time->jd d t)))
|
||||
|
||||
(: jd->datetime (-> Exact-Rational DateTime))
|
||||
(define (jd->datetime jd)
|
||||
(define ejd (inexact->exact jd))
|
||||
(define-values (d t) (jd->date+time ejd))
|
||||
(date+time->datetime d t))
|
||||
|
||||
(: datetime (->* (Natural) (Month Natural Natural Natural Natural Natural) DateTime))
|
||||
(define (datetime year [month 1] [day 1] [hour 0] [minute 0] [second 0] [nano 0])
|
||||
(date+time->datetime (date year month day)
|
||||
(make-time hour minute second nano)))
|
||||
|
||||
(: datetime->iso8601 (-> DateTime String))
|
||||
(define (datetime->iso8601 dt)
|
||||
(format "~aT~a"
|
||||
(date->iso8601 (datetime->date dt))
|
||||
(time->iso8601 (datetime->time dt))))
|
||||
|
||||
(: datetime=? (-> DateTime DateTime Boolean))
|
||||
(define (datetime=? dt1 dt2)
|
||||
(= (datetime->jd dt1) (datetime->jd dt2)))
|
||||
|
||||
(: datetime<? (-> DateTime DateTime Boolean))
|
||||
(define (datetime<? dt1 dt2)
|
||||
(< (datetime->jd dt1) (datetime->jd dt2)))
|
||||
|
||||
(: datetime<=? (-> DateTime DateTime Boolean))
|
||||
(define (datetime<=? dt1 dt2)
|
||||
(<= (datetime->jd dt1) (datetime->jd dt2)))
|
||||
|
||||
(: date+time->jd (-> Date Time Exact-Rational))
|
||||
(define (date+time->jd d t)
|
||||
(define jdn (date->jdn d))
|
||||
(define day-ns (time->ns t))
|
||||
|
||||
(+ (- jdn 1/2)
|
||||
(/ day-ns NS/DAY)))
|
||||
|
||||
(: jd->date+time (-> Exact-Rational (Values Date Time)))
|
||||
(define (jd->date+time jd)
|
||||
(define jdn (jd->jdn jd))
|
||||
(define d (jdn->date jdn))
|
||||
(define day-ns (jd->day-ns jd))
|
||||
(define t (day-ns->time day-ns))
|
||||
|
||||
(values d t))
|
||||
|
||||
(: jd->jdn (-> Exact-Rational Exact-Rational))
|
||||
(define (jd->jdn jd)
|
||||
(define lo (exact-floor jd))
|
||||
|
||||
;; math-class rounding: round up for >= 1/2
|
||||
(if (>= (- jd lo) 1/2)
|
||||
(add1 lo)
|
||||
lo))
|
||||
|
||||
(: jd->day-ns (-> Exact-Rational Natural))
|
||||
(define (jd->day-ns jd)
|
||||
(define base (- jd 1/2))
|
||||
(define frac (- base (exact-floor base)))
|
||||
(define r (exact-round (* frac NS/DAY)))
|
||||
(unless (index? r) (error "jd->day-ns"))
|
||||
r)
|
||||
|
||||
(: jd->posix (-> Exact-Rational Exact-Rational))
|
||||
(define (jd->posix jd)
|
||||
(* 86400 (- jd (+ 2440587 1/2))))
|
||||
|
||||
(: posix->jd (-> Exact-Rational Exact-Rational))
|
||||
(define (posix->jd posix)
|
||||
(+ (/ posix 86400) (+ 2440587 1/2)))
|
||||
|
||||
(: datetime-add-nanoseconds (-> DateTime Integer DateTime))
|
||||
(define (datetime-add-nanoseconds dt n)
|
||||
(jd->datetime
|
||||
(+ (datetime->jd dt)
|
||||
(/ n NS/DAY))))
|
||||
|
||||
(: datetime-add-seconds (-> DateTime Integer DateTime))
|
||||
(define (datetime-add-seconds dt n)
|
||||
(datetime-add-nanoseconds dt (* n NS/SECOND)))
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
#lang typed/racket/base
|
||||
(require trivial/no-colon)
|
||||
|
||||
;; Time deltas
|
||||
|
||||
(provide;/contract
|
||||
datetime-months-between ;(-> datetime? datetime? exact-integer?)]
|
||||
datetime-days-between ;(-> datetime? datetime? exact-integer?)]
|
||||
datetime-nanoseconds-between ;(-> datetime? datetime? exact-integer?)])
|
||||
)
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
|
||||
(require
|
||||
racket/match
|
||||
"core-adapter.rkt"
|
||||
"gregor-adapter.rkt"
|
||||
(only-in racket/math exact-floor))
|
||||
(require
|
||||
"ymd.rkt"
|
||||
)
|
||||
(require "hmsn.rkt"
|
||||
)
|
||||
(require "date.rkt"
|
||||
)
|
||||
(require "datetime.rkt"
|
||||
)
|
||||
|
||||
;; =============================================================================
|
||||
|
||||
;; difference
|
||||
(: datetime-months-between (-> DateTime DateTime Integer))
|
||||
(define (datetime-months-between dt1 dt2)
|
||||
(cond [(datetime<? dt2 dt1)
|
||||
(- (datetime-months-between dt2 dt1))]
|
||||
[else
|
||||
(: d1 Date)
|
||||
(define d1 (datetime->date dt1))
|
||||
(: d2 Date)
|
||||
(define d2 (datetime->date dt2))
|
||||
|
||||
(match* ((date->ymd d1) (date->ymd d2))
|
||||
[((YMD y1 m1 d1) (YMD y2 m2 d2))
|
||||
(: diff Integer)
|
||||
(define diff
|
||||
(+ (* (- y2 y1) 12)
|
||||
m2
|
||||
(- m1)))
|
||||
(: start-dom Natural)
|
||||
(define start-dom
|
||||
(let ([r (if (and (> d1 d2)
|
||||
(= (days-in-month y2 m2) d2))
|
||||
d2
|
||||
d1)])
|
||||
(abs r)))
|
||||
(: dt1a DateTime)
|
||||
(define dt1a (date+time->datetime (date y1 m1 start-dom) (datetime->time dt1)))
|
||||
|
||||
(define ts1 (- (datetime->jd dt1a) (datetime->jd (datetime y1 m1))))
|
||||
(define ts2 (- (datetime->jd dt2) (datetime->jd (datetime y2 m2))))
|
||||
(if (< ts2 ts1)
|
||||
(sub1 diff)
|
||||
diff)])]))
|
||||
|
||||
(: datetime-days-between (-> DateTime DateTime Integer))
|
||||
(define (datetime-days-between dt1 dt2)
|
||||
(exact-floor (- (datetime->jd dt2) (datetime->jd dt1))))
|
||||
|
||||
(: datetime-nanoseconds-between (-> DateTime DateTime Integer))
|
||||
(define (datetime-nanoseconds-between dt1 dt2)
|
||||
(- (datetime->jdns dt2)
|
||||
(datetime->jdns dt1)))
|
||||
|
||||
(: datetime->jdns (-> DateTime Integer))
|
||||
(define (datetime->jdns dt)
|
||||
(exact-floor (* (datetime->jd dt) NS/DAY)))
|
|
@ -1,24 +0,0 @@
|
|||
#lang typed/racket/base
|
||||
(require trivial/no-colon)
|
||||
|
||||
(require
|
||||
"core-adapter.rkt")
|
||||
|
||||
(require "gregor-structs.rkt"
|
||||
)
|
||||
|
||||
(provide
|
||||
Date Date?
|
||||
Date-ymd
|
||||
Date-jdn
|
||||
Time Time?
|
||||
Time-hmsn
|
||||
Time-ns
|
||||
DateTime DateTime?
|
||||
DateTime-date
|
||||
DateTime-time
|
||||
DateTime-jd
|
||||
Moment Moment?
|
||||
Moment-datetime/local
|
||||
Moment-utc-offset
|
||||
Moment-zone)
|
|
@ -1,28 +0,0 @@
|
|||
#lang typed/racket/base
|
||||
(require trivial/no-colon)
|
||||
|
||||
(require
|
||||
"core-adapter.rkt")
|
||||
|
||||
(provide
|
||||
(struct-out Date)
|
||||
(struct-out Time)
|
||||
(struct-out DateTime)
|
||||
(struct-out Moment))
|
||||
|
||||
;; Structs from the main gregor modules
|
||||
;; `date.rkt`, `time.rkt`, `datetime.rkt`, `moment-base.rkt`
|
||||
|
||||
(struct Date ([ymd : YMD]
|
||||
[jdn : Integer]))
|
||||
|
||||
(struct Time ([hmsn : HMSN] [ns : Natural]))
|
||||
|
||||
(struct DateTime ([date : Date]
|
||||
[time : Time]
|
||||
[jd : Exact-Rational]))
|
||||
|
||||
(struct Moment ([datetime/local : DateTime]
|
||||
[utc-offset : Integer]
|
||||
[zone : (U String #f)]))
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
#lang typed/racket/base
|
||||
(require trivial/no-colon)
|
||||
|
||||
;; Core:
|
||||
;; Hours, Minutes, Seconds, Nanoseconds
|
||||
;; constants and conversions
|
||||
|
||||
(provide
|
||||
NS/MICRO
|
||||
NS/MILLI
|
||||
NS/SECOND
|
||||
NS/MINUTE
|
||||
NS/HOUR
|
||||
NS/DAY
|
||||
MILLI/DAY
|
||||
hmsn->day-ns
|
||||
day-ns->hmsn)
|
||||
|
||||
(require
|
||||
racket/match
|
||||
"core-adapter.rkt")
|
||||
|
||||
;; =============================================================================
|
||||
|
||||
(: NS/SECOND Natural)
|
||||
(define NS/SECOND 1000000000)
|
||||
(: NS/MILLI Natural)
|
||||
(define NS/MILLI 1000000)
|
||||
;; (define NS/MILLI (/ NS/SECOND 1000))
|
||||
(: NS/MICRO Natural)
|
||||
(define NS/MICRO 1000)
|
||||
;; (define NS/MICRO (/ NS/MILLI 1000))
|
||||
(: NS/MINUTE Natural)
|
||||
(define NS/MINUTE (* NS/SECOND 60))
|
||||
(: NS/HOUR Natural)
|
||||
(define NS/HOUR (* NS/MINUTE 60))
|
||||
(: NS/DAY Natural)
|
||||
(define NS/DAY (* 86400 NS/SECOND))
|
||||
(: MILLI/DAY Natural)
|
||||
(define MILLI/DAY 86400000)
|
||||
;; (define MILLI/DAY (/ NS/DAY NS/MILLI))
|
||||
(: DAYS/NS Exact-Rational)
|
||||
(define DAYS/NS (/ 1 NS/DAY))
|
||||
|
||||
;; (define day-ns/c (integer-in 0 (sub1 NS/DAY)))
|
||||
;; Codomain of hmsn->day-ns should be a day-ns/c
|
||||
(: hmsn->day-ns (-> HMSN Natural))
|
||||
(define (hmsn->day-ns hmsn)
|
||||
(match-define (HMSN h m s n) hmsn)
|
||||
(define r (+ (* NS/HOUR h)
|
||||
(* NS/MINUTE m)
|
||||
(* NS/SECOND s)
|
||||
n))
|
||||
(unless (index? r)
|
||||
(error "nope"))
|
||||
r)
|
||||
|
||||
(: day-ns->hmsn (-> Natural HMSN))
|
||||
(define (day-ns->hmsn ns)
|
||||
(let* ([h (quotient ns NS/HOUR)]
|
||||
[ns (- ns (* h NS/HOUR))]
|
||||
[m (quotient ns NS/MINUTE)]
|
||||
[ns (- ns (* m NS/MINUTE))]
|
||||
[s (quotient ns NS/SECOND)]
|
||||
[ns (- ns (* s NS/SECOND))])
|
||||
(HMSN h m s ns)))
|
|
@ -1,143 +0,0 @@
|
|||
#lang typed/racket/base
|
||||
(require trivial/no-colon)
|
||||
|
||||
(require
|
||||
"../base/types.rkt"
|
||||
"gregor-adapter.rkt"
|
||||
"tzinfo-adapter.rkt"
|
||||
)
|
||||
(require "date.rkt"
|
||||
)
|
||||
(require "time.rkt"
|
||||
)
|
||||
(require "datetime.rkt"
|
||||
)
|
||||
(require "moment.rkt"
|
||||
)
|
||||
(require "clock.rkt"
|
||||
)
|
||||
(require "difference.rkt"
|
||||
)
|
||||
|
||||
;; =============================================================================
|
||||
|
||||
(: HISTORIC-DATES (-> (Listof DateTime)))
|
||||
(define (HISTORIC-DATES)
|
||||
(list
|
||||
;(datetime YEAR MONTH DAY HOUR MINUTE SECOND NANOSECOND)
|
||||
(datetime 2001 9 11 8 46) ;; 9/11 part I
|
||||
(datetime 2001 9 11 9 3) ;; 9/11 part II
|
||||
(datetime 1944 6 6 6 6 6 6) ;; D-Day
|
||||
(datetime 1984)
|
||||
(datetime 1963 11 22 12 30) ;; Kennedy
|
||||
(datetime 1865 4 14 10) ;; Lincoln
|
||||
(datetime 1881 7 2) ;; Garfield
|
||||
(datetime 1901 9 6) ;; McKinley
|
||||
(datetime 1933 2 15) ;; Roosevelt
|
||||
(datetime 1912 10 14) ;; Taft
|
||||
(datetime 1928 11 19) ;; Hoover
|
||||
(datetime 1950 11 1) ;; Truman
|
||||
(datetime 1835 1 30) ;; Jackson
|
||||
(datetime 1989 11 9) ;; Berlin Wall
|
||||
(datetime 1969 7 20 20 18) ;; Lunar landing
|
||||
(datetime 1977 8 16) ;; Elvis
|
||||
(datetime 1980 12 8) ;; Lennon
|
||||
(datetime 2013 6 18) ;; Kanye releases Yeezus
|
||||
(datetime 1998 9 28) ;; Pokemon Red released
|
||||
(datetime 1991 4 29) ;; Sarah bday
|
||||
(datetime 1922 2 2) ;; Ulysses released
|
||||
(datetime 12)
|
||||
(datetime 1030) ;; Leif Erikson landing
|
||||
(datetime 1898 4) ;; Spanish-American war begins
|
||||
(datetime 1099 7 10) ;; El Cid dies
|
||||
))
|
||||
(: RANDOM-DATES (-> (Listof DateTime)))
|
||||
(define (RANDOM-DATES)
|
||||
(list
|
||||
(datetime 324 2 1 4 32 66 23)
|
||||
(datetime 6 9 12 0 55 6 8)
|
||||
(datetime 1111 12 30 8 48 11 44)
|
||||
(datetime 32 5 8 12 2 41 39) (datetime 6 6 6 6 6 6 6)
|
||||
(datetime 8 6 7 5 3 0 9)
|
||||
(datetime 1251 3 18 6)
|
||||
(datetime 1386 2 1 0)
|
||||
(datetime 123 4 5 12 53)
|
||||
(datetime 2002 11 42 32)
|
||||
(datetime 777 7 77 77 77)
|
||||
(datetime 1 2 3 4 5 6 7)
|
||||
(datetime 9999 12 30 30 30 30 30)
|
||||
))
|
||||
|
||||
;; -- tests
|
||||
|
||||
(: test-clock (-> Void))
|
||||
(define (test-clock)
|
||||
(parameterize ([current-clock (lambda () 1)])
|
||||
;; -- today
|
||||
(unless (date=? (today/utc) (date 1970)) (error "test1"))
|
||||
(unless (date=? (today #:tz "America/Chicago") (date 1969 12 31)) (error "test2"))
|
||||
;; -- current-time
|
||||
(unless (time=? (current-time/utc) (make-time 0 0 1)) (error "test 3"))
|
||||
(unless (time=? (current-time #:tz "America/Chicago") (make-time 18 0 1)) (error "test4"))
|
||||
;; -- now
|
||||
(unless (datetime=? (now/utc) (datetime 1970 1 1 0 0 1)) (error "test5"))
|
||||
(unless (datetime=? (now #:tz "America/Chicago") (datetime 1969 12 31 18 0 1)) (error "test6"))
|
||||
|
||||
;; -- "moment"
|
||||
(unless (moment=? (now/moment/utc) (moment 1970 1 1 0 0 1 #:tz UTC)) (error "test7"))
|
||||
;; 2015-04-25: Can't type check! Need help
|
||||
;; (unless (moment=? (now/moment #:tz "America/Chicago")
|
||||
;; (moment 1969 12 31 18 0 1 0 #:tz "America/Chicago")) (error "test8"))
|
||||
))
|
||||
|
||||
(: test-iso (-> (Listof DateTime) Void))
|
||||
(define (test-iso dates)
|
||||
(parameterize ([current-clock (lambda () 1463207954418177/1024000)])
|
||||
;; -- test-case "today"
|
||||
(let ([d (today)])
|
||||
(unless (string=? "2015-04-13" (date->iso8601 d)) (error "test9")))
|
||||
|
||||
;; -- test-case "current-time"
|
||||
(let ([t (current-time)])
|
||||
(unless (string=? "04:33:37.986500977" (time->iso8601 t)) (error "test10")))
|
||||
|
||||
;; -- test-case "now"
|
||||
(let ([n (now)])
|
||||
(unless (string=? "2015-04-13T04:33:37.986500977" (datetime->iso8601 n)) (error "test11")))
|
||||
|
||||
;; -- test-case "now/moment"
|
||||
(let ([n (now/moment)])
|
||||
(unless (string=? "2015-04-13T04:33:37.986500977-04:00[America/New_York]" (moment->iso8601/tzid n)) (error "test12")))
|
||||
)
|
||||
(for ([d1 dates])
|
||||
(datetime->iso8601 d1)
|
||||
(time->iso8601 (datetime->time d1))
|
||||
(date->iso8601 (datetime->date d1)))
|
||||
)
|
||||
|
||||
(: test-difference (-> (Listof DateTime) Void))
|
||||
(define (test-difference dates)
|
||||
(for* ([dt1 dates]
|
||||
[dt2 dates])
|
||||
(datetime<=? dt1 dt2)
|
||||
(datetime-months-between dt1 dt2)
|
||||
(datetime-days-between dt1 dt2)
|
||||
(datetime-nanoseconds-between dt1 dt2)
|
||||
(moment=?
|
||||
(posix->moment (datetime->posix dt1) UTC)
|
||||
(posix->moment (datetime->posix dt2) UTC))
|
||||
))
|
||||
|
||||
(: main (-> Natural Boolean Void))
|
||||
(define (main N large?)
|
||||
(define dates
|
||||
(if large?
|
||||
(append (HISTORIC-DATES) (RANDOM-DATES))
|
||||
(HISTORIC-DATES)))
|
||||
(for ([i (in-range N)])
|
||||
(test-clock)
|
||||
(test-iso dates)
|
||||
(test-difference dates)))
|
||||
|
||||
;(time (main 10 #f)) ;;134ms
|
||||
(time (main 10 #t)) ;;347ms
|
|
@ -1,51 +0,0 @@
|
|||
#lang typed/racket/base
|
||||
(require trivial/no-colon)
|
||||
|
||||
;; Support for moment.rkt
|
||||
;; (Works together with offset-resolvers.rkt)
|
||||
|
||||
(provide
|
||||
moment->iso8601
|
||||
moment->iso8601/tzid
|
||||
make-moment
|
||||
)
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
|
||||
(require
|
||||
racket/match
|
||||
"gregor-adapter.rkt"
|
||||
(only-in racket/format ~r)
|
||||
)
|
||||
(require "datetime.rkt"
|
||||
)
|
||||
|
||||
;; =============================================================================
|
||||
|
||||
(: moment->iso8601/tzid (-> Moment String))
|
||||
(define (moment->iso8601/tzid m)
|
||||
(: iso String)
|
||||
(define iso (moment->iso8601 m))
|
||||
(match m
|
||||
[(Moment _ _ z) #:when z (format "~a[~a]" iso z)]
|
||||
[_ iso]))
|
||||
|
||||
(: moment->iso8601 (-> Moment String))
|
||||
(define (moment->iso8601 m)
|
||||
(match m
|
||||
[(Moment d 0 _)
|
||||
(string-append (datetime->iso8601 d) "Z")]
|
||||
[(Moment d o _)
|
||||
(define sign (if (< o 0) "-" "+"))
|
||||
(define sec (abs o))
|
||||
(define hrs (quotient sec 3600))
|
||||
(define min (quotient (- sec (* hrs 3600)) 60))
|
||||
(format "~a~a~a:~a"
|
||||
(datetime->iso8601 d)
|
||||
sign
|
||||
(~r hrs #:min-width 2 #:pad-string "0" #:sign #f)
|
||||
(~r min #:min-width 2 #:pad-string "0" #:sign #f))]))
|
||||
|
||||
(: make-moment (-> DateTime Integer (U String #f) Moment))
|
||||
(define (make-moment dt off z)
|
||||
(Moment dt off (and z (string->immutable-string z))))
|
|
@ -1,180 +0,0 @@
|
|||
#lang typed/racket/base
|
||||
(require trivial/no-colon)
|
||||
|
||||
;; Moments in time
|
||||
|
||||
;; Need the requires on top to stop syntax errors; opaques must
|
||||
;; come lexically before their use
|
||||
(require
|
||||
"../base/types.rkt"
|
||||
"gregor-adapter.rkt"
|
||||
racket/match
|
||||
(only-in racket/math exact-round)
|
||||
"tzinfo-adapter.rkt"
|
||||
)
|
||||
(require "hmsn.rkt"
|
||||
)
|
||||
(require "datetime.rkt"
|
||||
)
|
||||
(require "moment-base.rkt"
|
||||
)
|
||||
(require "offset-resolvers.rkt"
|
||||
)
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
|
||||
(provide;/contract
|
||||
current-timezone ;(parameter/c tz/c)]
|
||||
moment ;(->i ([year exact-integer?])
|
||||
; ([month (integer-in 1 12)]
|
||||
; [day (year month) (day-of-month/c year month)]
|
||||
; [hour (integer-in 0 23)]
|
||||
; [minute (integer-in 0 59)]
|
||||
; [second (integer-in 0 59)]
|
||||
; [nanosecond (integer-in 0 (sub1 NS/SECOND))]
|
||||
; #:tz [tz tz/c]
|
||||
; #:resolve-offset [resolve offset-resolver/c])
|
||||
; [res moment?])]
|
||||
datetime+tz->moment ;(-> datetime? tz/c offset-resolver/c moment?)]
|
||||
moment->iso8601 ;(-> moment? string?)]
|
||||
moment->iso8601/tzid ;(-> moment? string?)]
|
||||
moment->datetime/local ;(-> moment? datetime?)]
|
||||
moment->utc-offset ;(-> moment? exact-integer?)]
|
||||
moment->timezone ;(-> moment? tz/c)]
|
||||
moment->tzid ;(-> moment? (or/c string? #f))]
|
||||
moment->jd ;(-> moment? rational?)]
|
||||
moment->posix ;(-> moment? rational?)]
|
||||
posix->moment ;(-> rational? tz/c moment?)]
|
||||
moment-add-nanoseconds ;(-> moment? exact-integer? moment?)]
|
||||
moment-in-utc ;(-> moment? moment?)]
|
||||
timezone-adjust ;(-> moment? tz/c moment?)]
|
||||
timezone-coerce ;(->i ([m moment?]
|
||||
; [z tz/c])
|
||||
; (#:resolve-offset [r offset-resolver/c])
|
||||
; [res moment?])]
|
||||
moment=? ;(-> moment? moment? boolean?)]
|
||||
moment<? ;(-> moment? moment? boolean?)]
|
||||
moment<=? ;(-> moment? moment? boolean?)]
|
||||
UTC ;tz/c]
|
||||
)
|
||||
|
||||
;; =============================================================================
|
||||
|
||||
(: current-timezone (Parameterof (U tz #f)))
|
||||
(define current-timezone (make-parameter (system-tzid)))
|
||||
|
||||
(: moment (->* (Natural) (Month
|
||||
Natural Natural Natural Natural Natural
|
||||
#:tz (U tz #f)
|
||||
#:resolve-offset (-> (U tzgap tzoverlap)
|
||||
DateTime
|
||||
(U String #f)
|
||||
(U #f Moment) Moment)
|
||||
)
|
||||
Moment))
|
||||
(define (moment year [month 1] [day 1] [hour 0] [minute 0] [second 0] [nano 0]
|
||||
#:tz [tz (current-timezone)]
|
||||
#:resolve-offset [resolve resolve-offset/raise])
|
||||
(when (eq? tz #f) (error "no timezone"))
|
||||
(datetime+tz->moment (datetime year month day hour minute second nano) tz resolve))
|
||||
|
||||
(: datetime+tz->moment (-> DateTime
|
||||
(U Integer String)
|
||||
(-> (U tzgap tzoverlap)
|
||||
DateTime
|
||||
(U String #f)
|
||||
(U Moment #f) Moment)
|
||||
Moment))
|
||||
(define (datetime+tz->moment dt zone resolve)
|
||||
(cond [(string? zone)
|
||||
(define res (local-seconds->tzoffset zone (exact-round (datetime->posix dt))))
|
||||
(cond
|
||||
[(tzoffset? res)
|
||||
(make-moment dt (tzoffset-utc-seconds res) zone)]
|
||||
[else (resolve res dt zone #f)])]
|
||||
[(index? zone)
|
||||
(make-moment dt zone #f)]
|
||||
[else (error (format "datetime+tz->moment unknown zone ~a" zone))]))
|
||||
|
||||
(define moment->datetime/local Moment-datetime/local)
|
||||
(define moment->utc-offset Moment-utc-offset)
|
||||
(define moment->tzid Moment-zone)
|
||||
|
||||
(: moment->timezone (-> Moment tz))
|
||||
(define (moment->timezone m)
|
||||
(or (moment->tzid m)
|
||||
(moment->utc-offset m)))
|
||||
|
||||
(: moment-in-utc (-> Moment Moment))
|
||||
(define (moment-in-utc m)
|
||||
(if (equal? UTC (moment->timezone m))
|
||||
m
|
||||
(timezone-adjust m UTC)))
|
||||
|
||||
(: moment->jd (-> Moment Exact-Rational))
|
||||
(define (moment->jd m)
|
||||
(datetime->jd
|
||||
(moment->datetime/local
|
||||
(moment-in-utc m))))
|
||||
|
||||
(: moment->posix (-> Moment Exact-Rational))
|
||||
(define (moment->posix m)
|
||||
(datetime->posix
|
||||
(moment->datetime/local
|
||||
(moment-in-utc m))))
|
||||
|
||||
(: posix->moment (-> Exact-Rational tz Moment))
|
||||
(define (posix->moment p z)
|
||||
(: off Integer)
|
||||
(define off
|
||||
(cond [(string? z) (tzoffset-utc-seconds (utc-seconds->tzoffset z p))]
|
||||
[else 0]))
|
||||
(define dt (posix->datetime (+ p off)))
|
||||
(unless (string? z) (error "posix->moment: can't call make-moment with an integer"))
|
||||
(make-moment dt off z))
|
||||
|
||||
(: moment-add-nanoseconds (-> Moment Natural Moment))
|
||||
(define (moment-add-nanoseconds m n)
|
||||
(posix->moment (+ (moment->posix m) (* n (/ 1 NS/SECOND)))
|
||||
(moment->timezone m)))
|
||||
|
||||
(: timezone-adjust (-> Moment (U Natural String) Moment))
|
||||
(define (timezone-adjust m z)
|
||||
(: dt DateTime)
|
||||
(define dt (error 'foo));(Moment-datetime/local m))
|
||||
(: neg-sec Integer)
|
||||
(define neg-sec (error 'foo));(Moment-utc-offset m))
|
||||
(: dt/utc DateTime)
|
||||
(define dt/utc
|
||||
(datetime-add-seconds dt (- neg-sec)))
|
||||
(cond [(string? z)
|
||||
(define posix (datetime->posix dt/utc))
|
||||
(match-define (tzoffset offset _ _) (utc-seconds->tzoffset z posix))
|
||||
(define local (datetime-add-seconds dt/utc offset))
|
||||
(make-moment local offset z)]
|
||||
[else
|
||||
(define local (datetime-add-seconds dt/utc z))
|
||||
(make-moment local z #f)]))
|
||||
|
||||
(: timezone-coerce (->* [Moment (U Natural String)]
|
||||
(#:resolve-offset (-> (U tzgap tzoverlap) DateTime (U String #f) (U #f Moment) Moment))
|
||||
Moment))
|
||||
(define (timezone-coerce m z #:resolve-offset [resolve resolve-offset/raise])
|
||||
(datetime+tz->moment (moment->datetime/local m) z resolve))
|
||||
|
||||
(: moment=? (-> Moment Moment Boolean))
|
||||
(define (moment=? m1 m2)
|
||||
(= (moment->jd m1) (moment->jd m2)))
|
||||
|
||||
(: moment<? (-> Moment Moment Boolean))
|
||||
(define (moment<? m1 m2)
|
||||
(< (moment->jd m1) (moment->jd m2)))
|
||||
|
||||
(: moment<=? (-> Moment Moment Boolean))
|
||||
(define (moment<=? m1 m2)
|
||||
(<= (moment->jd m1) (moment->jd m2)))
|
||||
|
||||
(: UTC String)
|
||||
(define UTC "Etc/UTC")
|
||||
|
||||
|
|
@ -1,141 +0,0 @@
|
|||
#lang typed/racket/base
|
||||
(require trivial/no-colon)
|
||||
|
||||
;; Resolving offsets between moments
|
||||
|
||||
(require
|
||||
"tzinfo-adapter.rkt"
|
||||
"core-adapter.rkt"
|
||||
"gregor-adapter.rkt"
|
||||
racket/match)
|
||||
(require "hmsn.rkt"
|
||||
)
|
||||
(require "datetime.rkt"
|
||||
)
|
||||
(require "moment-base.rkt"
|
||||
)
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
|
||||
(provide
|
||||
resolve-gap/pre
|
||||
resolve-gap/post
|
||||
resolve-gap/push
|
||||
|
||||
resolve-overlap/pre
|
||||
resolve-overlap/post
|
||||
resolve-overlap/retain
|
||||
|
||||
resolve-offset/pre
|
||||
resolve-offset/post
|
||||
resolve-offset/post-gap/pre-overlap
|
||||
resolve-offset/retain
|
||||
resolve-offset/push
|
||||
resolve-offset/raise
|
||||
|
||||
offset-resolver
|
||||
)
|
||||
;; =============================================================================
|
||||
|
||||
;; -- from exn.rkt
|
||||
|
||||
(struct exn:gregor exn:fail ())
|
||||
(struct exn:gregor:invalid-offset exn:gregor ())
|
||||
|
||||
(: raise-invalid-offset (-> Any DateTime Any Any Moment))
|
||||
(define (raise-invalid-offset g/o target-dt target-tzid orig)
|
||||
(raise
|
||||
(exn:gregor:invalid-offset
|
||||
(format "Illegal moment: local time ~a ~a in time zone ~a"
|
||||
(datetime->iso8601 target-dt)
|
||||
(if (tzgap? g/o)
|
||||
"does not exist"
|
||||
"is ambiguous")
|
||||
target-tzid)
|
||||
(current-continuation-marks))))
|
||||
|
||||
;; -- from `offset-resolvers.rkt`
|
||||
|
||||
(: resolve-gap/pre (-> tzgap DateTime (U String #f) (U #f Moment) Moment))
|
||||
(define (resolve-gap/pre gap target-dt target-tzid orig)
|
||||
;(define tm (tzgap-starts-at gap))
|
||||
;(define delta (tzoffset-utc-seconds (tzgap-offset-before gap)))
|
||||
(match-define (tzgap tm (tzoffset delta _ _) _) gap)
|
||||
(make-moment (posix->datetime (+ tm delta (- (/ 1 NS/SECOND)))) delta target-tzid))
|
||||
|
||||
(: resolve-gap/post (-> tzgap DateTime (U String #f) (U #f Moment) Moment))
|
||||
(define (resolve-gap/post gap target-dt target-tzid orig)
|
||||
;(match-define (tzgap _ _ (tzoffset delta _ _)) gap)
|
||||
(define tm (tzgap-starts-at gap))
|
||||
(define delta (tzoffset-utc-seconds (tzgap-offset-before gap)))
|
||||
(define sum (+ tm delta))
|
||||
(make-moment (posix->datetime sum) delta target-tzid))
|
||||
|
||||
(: resolve-gap/push (-> tzgap DateTime (U String #f) (U #f Moment) Moment))
|
||||
(define (resolve-gap/push gap target-dt target-tzid orig)
|
||||
;(match-define (tzgap tm (tzoffset delta1 _ _) (tzoffset delta2 _ _)) gap)
|
||||
(define tm (tzgap-starts-at gap))
|
||||
(define delta1 (tzoffset-utc-seconds (tzgap-offset-before gap)))
|
||||
(define delta2 (tzoffset-utc-seconds (tzgap-offset-after gap)))
|
||||
(make-moment (posix->datetime (+ (datetime->posix target-dt) (- delta2 delta1))) delta2 target-tzid))
|
||||
|
||||
(: resolve-overlap/pre (-> tzoverlap DateTime (U String #f) (U #f Moment) Moment))
|
||||
(define (resolve-overlap/pre overlap target-dt target-tzid orig)
|
||||
(match-define (tzoverlap (tzoffset delta _ _) _) overlap)
|
||||
(make-moment target-dt delta target-tzid))
|
||||
|
||||
(: resolve-overlap/post (-> tzoverlap DateTime (U String #f) (U #f Moment) Moment))
|
||||
(define (resolve-overlap/post overlap target-dt target-tzid orig)
|
||||
(match-define (tzoverlap _ (tzoffset delta _ _)) overlap)
|
||||
(make-moment target-dt delta target-tzid))
|
||||
|
||||
(: resolve-overlap/retain (-> tzoverlap DateTime (U String #f) (U #f Moment) Moment))
|
||||
(define (resolve-overlap/retain overlap target-dt target-tzid orig)
|
||||
;(match-define (tzoverlap (tzoffset delta1 _ _) (tzoffset delta2 _ _)) overlap)
|
||||
(define delta1 (tzoffset-utc-seconds (tzoverlap-offset-before overlap)))
|
||||
(define delta2 (tzoffset-utc-seconds (tzoverlap-offset-after overlap)))
|
||||
(make-moment target-dt
|
||||
(or (and orig (= (Moment-utc-offset orig) delta1) delta1)
|
||||
delta2)
|
||||
target-tzid))
|
||||
|
||||
(: offset-resolver (-> (-> tzgap DateTime (U String #f) (U #f Moment) Moment)
|
||||
(-> tzoverlap DateTime (U String #f) (U #f Moment) Moment)
|
||||
(-> (U tzgap tzoverlap) DateTime (U String #f) (U #f Moment) Moment)))
|
||||
(define (offset-resolver rg ro)
|
||||
(λ ([g/o : (U tzgap tzoverlap)]
|
||||
[target-dt : DateTime]
|
||||
[target-tzid : (U String #f)]
|
||||
[orig : (U #f Moment)])
|
||||
(cond [(tzgap? g/o)
|
||||
(rg g/o target-dt target-tzid orig)]
|
||||
[else
|
||||
(ro g/o target-dt target-tzid orig)])))
|
||||
;; (define fn (if (tzgap? g/o) rg ro))
|
||||
;; (fn g/o target-dt target-tzid orig)))
|
||||
|
||||
(: resolve-offset/pre (-> (U tzgap tzoverlap) DateTime (U String #f) (U #f Moment) Moment))
|
||||
(define resolve-offset/pre
|
||||
(offset-resolver resolve-gap/pre resolve-overlap/pre))
|
||||
|
||||
(: resolve-offset/post (-> (U tzgap tzoverlap) DateTime (U String #f) (U #f Moment) Moment))
|
||||
(define resolve-offset/post
|
||||
(offset-resolver resolve-gap/post resolve-overlap/post))
|
||||
|
||||
(: resolve-offset/post-gap/pre-overlap (-> (U tzgap tzoverlap) DateTime (U String #f) (U #f Moment) Moment))
|
||||
(define resolve-offset/post-gap/pre-overlap
|
||||
(offset-resolver resolve-gap/post resolve-overlap/pre))
|
||||
|
||||
(: resolve-offset/retain (-> (U tzgap tzoverlap) DateTime (U String #f) (U #f Moment) Moment))
|
||||
(define resolve-offset/retain
|
||||
(offset-resolver resolve-gap/post
|
||||
resolve-overlap/retain))
|
||||
|
||||
(: resolve-offset/push (-> (U tzgap tzoverlap) DateTime (U String #f) (U #f Moment) Moment))
|
||||
(define resolve-offset/push
|
||||
(offset-resolver resolve-gap/push
|
||||
resolve-overlap/post))
|
||||
|
||||
(: resolve-offset/raise (-> (U tzgap tzoverlap) DateTime (U String #f) (U Moment #f) Moment))
|
||||
(define (resolve-offset/raise g/o target-dt target-tzid orig)
|
||||
(raise-invalid-offset g/o target-dt target-tzid orig))
|
|
@ -1,15 +0,0 @@
|
|||
#lang typed/racket/base
|
||||
(require trivial/no-colon)
|
||||
|
||||
;; Adapter for gregor's `structs.rkt` file.
|
||||
|
||||
(provide
|
||||
(struct-out YMD)
|
||||
(struct-out HMSN)
|
||||
Month)
|
||||
|
||||
(require
|
||||
"../base/types.rkt")
|
||||
|
||||
(require "structs.rkt"
|
||||
)
|
|
@ -1,89 +0,0 @@
|
|||
#lang typed/racket/base
|
||||
(require trivial/no-colon)
|
||||
|
||||
;; Working with Time objects
|
||||
|
||||
(provide;/contract
|
||||
make-time ;(->i ([hour (integer-in 0 23)])
|
||||
; ([minute (integer-in 0 59)]
|
||||
; [second (integer-in 0 59)]
|
||||
; [nanosecond (integer-in 0 (sub1 NS/SECOND))])
|
||||
; [t time?])]
|
||||
time->hmsn ; (-> time? HMSN?)]
|
||||
time->ns ; (-> time? (integer-in 0 (sub1 NS/DAY)))]
|
||||
day-ns->time ; (-> (integer-in 0 (sub1 NS/DAY)) time?)]
|
||||
time->iso8601 ; (-> time? string?)]
|
||||
time=? ; (-> time? time? boolean?)]
|
||||
time<? ; (-> time? time? boolean?)]
|
||||
time<=? ; (-> time? time? boolean?)]
|
||||
)
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
|
||||
(require
|
||||
(only-in racket/format ~r)
|
||||
"core-adapter.rkt"
|
||||
"gregor-adapter.rkt"
|
||||
racket/match)
|
||||
(require
|
||||
"hmsn.rkt"
|
||||
)
|
||||
|
||||
;; =============================================================================
|
||||
|
||||
(: time-equal-proc (-> Time Time Boolean))
|
||||
(define (time-equal-proc x y)
|
||||
(= (Time-ns x) (Time-ns y)))
|
||||
|
||||
(: time-hash-proc (-> Time (-> Natural Integer) Integer))
|
||||
(define (time-hash-proc x fn)
|
||||
(fn (Time-ns x)))
|
||||
|
||||
(: time-write-proc (-> Time Output-Port Any Void))
|
||||
(define (time-write-proc t out mode)
|
||||
(fprintf out "#<time ~a>" (time->iso8601 t)))
|
||||
|
||||
(: time? (-> Any Boolean))
|
||||
(define time? Time?)
|
||||
|
||||
(: time->hmsn (-> Time HMSN))
|
||||
(define time->hmsn Time-hmsn)
|
||||
(: time->ns (-> Time Natural))
|
||||
(define (time->ns t)
|
||||
(Time-ns t))
|
||||
|
||||
(: hmsn->time (-> HMSN Time))
|
||||
(define (hmsn->time hmsn)
|
||||
(Time hmsn (hmsn->day-ns hmsn)))
|
||||
|
||||
(: day-ns->time (-> Natural Time))
|
||||
(define (day-ns->time ns)
|
||||
(Time (day-ns->hmsn ns) ns))
|
||||
|
||||
(: make-time (->* (Integer) (Integer Integer Integer) Time))
|
||||
(define (make-time h [m 0] [s 0] [n 0])
|
||||
(hmsn->time (HMSN h m s n)))
|
||||
|
||||
(: time->iso8601 (-> Time String))
|
||||
(define (time->iso8601 t)
|
||||
(: f (-> Integer Natural String))
|
||||
(define (f n l) (~r n #:min-width l #:pad-string "0"))
|
||||
|
||||
(match-define (HMSN h m s n) (time->hmsn t))
|
||||
(define fsec (+ s (/ n NS/SECOND)))
|
||||
(define pad (if (>= s 10) "" "0"))
|
||||
|
||||
(format "~a:~a:~a~a" (f h 2) (f m 2) pad (~r fsec #:precision 9)))
|
||||
|
||||
(: time=? (-> Time Time Boolean))
|
||||
(define (time=? t1 t2)
|
||||
(= (time->ns t1) (time->ns t2)))
|
||||
|
||||
(: time<=? (-> Time Time Boolean))
|
||||
(define (time<=? t1 t2)
|
||||
(<= (time->ns t1) (time->ns t2)))
|
||||
|
||||
(: time<? (-> Time Time Boolean))
|
||||
(define (time<? t1 t2)
|
||||
(< (time->ns t1) (time->ns t2)))
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
#lang typed/racket/base
|
||||
(require trivial/no-colon)
|
||||
|
||||
;; Adapter module for the tzinfo subproject
|
||||
|
||||
(require/typed/provide "../base/tzinfo/main.rkt"
|
||||
[system-tzid (-> (U tz #f))]
|
||||
[#:struct tzgap ([starts-at : Natural]
|
||||
[offset-before : tzoffset]
|
||||
[offset-after : tzoffset])]
|
||||
[#:struct tzoffset ([utc-seconds : Integer]
|
||||
[dst? : Boolean]
|
||||
[abbreviation : String])]
|
||||
[#:struct tzoverlap ([offset-before : tzoffset]
|
||||
[offset-after : tzoffset])]
|
||||
[local-seconds->tzoffset (-> String Integer (U tzoffset tzgap tzoverlap))]
|
||||
[utc-seconds->tzoffset (-> String Exact-Rational tzoffset)]
|
||||
)
|
||||
|
||||
(provide tz)
|
||||
(define-type tz (U String Integer))
|
||||
|
|
@ -1,243 +0,0 @@
|
|||
#lang typed/racket/base
|
||||
(require trivial/no-colon)
|
||||
|
||||
;; Core:
|
||||
;; Year-Month-Day
|
||||
;; Basic conversions
|
||||
|
||||
(provide;/contract
|
||||
ymd->jdn ; (-> YMD? exact-integer?)]
|
||||
jdn->ymd ; (-> exact-integer? YMD?)]
|
||||
jdn->wday ; (-> exact-integer? (integer-in 0 6))]
|
||||
jdn->iso-wday ; (-> exact-integer? (integer-in 1 7))]
|
||||
ymd->yday ; (-> YMD? (integer-in 1 366))]
|
||||
ymd->quarter ; (-> YMD? (integer-in 1 4))]
|
||||
ymd-add-years ; (-> YMD? exact-integer? YMD?)]
|
||||
ymd-add-months ; (-> YMD? exact-integer? YMD?)]
|
||||
leap-year? ; (-> exact-integer? boolean?)]
|
||||
days-in-month ; (-> exact-integer? (integer-in 1 12) (integer-in 28 31))]
|
||||
iso-weeks-in-year; (-> exact-integer? (or/c 52 53))]
|
||||
;; day-of-month/c ; any/c
|
||||
)
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
|
||||
(require
|
||||
racket/match
|
||||
(only-in racket/math exact-truncate exact-floor)
|
||||
"core-adapter.rkt")
|
||||
|
||||
;; =============================================================================
|
||||
|
||||
;; -- from `math.rkt`
|
||||
|
||||
(: div (-> Integer Integer Integer))
|
||||
(define (div x y)
|
||||
(define rem (remainder x y))
|
||||
(if (< (bitwise-xor rem y) 0)
|
||||
(sub1 (quotient x y))
|
||||
(quotient x y)))
|
||||
|
||||
(: mod (-> Integer Integer Integer))
|
||||
(define (mod x y)
|
||||
(define rem (remainder x y))
|
||||
(if (< (bitwise-xor rem y) 0)
|
||||
(+ rem y)
|
||||
rem))
|
||||
|
||||
(: mod1 (-> Integer Integer Integer))
|
||||
(define (mod1 x y)
|
||||
(- y (mod (- y x) y)))
|
||||
(: ymd->jdn (-> YMD Integer))
|
||||
(define (ymd->jdn ymd)
|
||||
(match-define (YMD y m d) ymd)
|
||||
(let-values ([(y m) (if (< m 3)
|
||||
(values (sub1 y) (+ m 12))
|
||||
(values y m))])
|
||||
(+ d
|
||||
(exact-truncate
|
||||
(/
|
||||
(- (* 153 m) 457)
|
||||
5))
|
||||
(* 365 y)
|
||||
(exact-floor
|
||||
(/ y 4))
|
||||
(-
|
||||
(exact-floor
|
||||
(/ y 100)))
|
||||
(exact-floor
|
||||
(/ y 400))
|
||||
1721119)))
|
||||
|
||||
;; -- from `ymd.rkt
|
||||
|
||||
(: jdn->ymd (-> Exact-Rational YMD))
|
||||
(define (jdn->ymd jdn)
|
||||
(let* ([x (exact-floor (/ (- jdn 1867216.25) 36524.25))]
|
||||
[a (+ jdn 1 x (- (exact-floor (/ x 4))))]
|
||||
[b (+ a 1524)]
|
||||
[c (exact-floor (/ (- b 122.1) 365.25))]
|
||||
[d (exact-floor (* 365.25 c))]
|
||||
[e (exact-floor (/ (- b d) 30.6001))]
|
||||
[dom (- b d (exact-floor (* 30.6001 e)))])
|
||||
(let-values ([(m y) (if (<= e 13)
|
||||
(values (sub1 e) (- c 4716))
|
||||
(values (- e 13) (- c 4715)))])
|
||||
(unless (and (index? y)
|
||||
(and (index? m) (< 0 m) (< m 13))
|
||||
(index? dom))
|
||||
(error "jdn->ymd"))
|
||||
(case m
|
||||
[(1) (YMD y 1 dom)]
|
||||
[(2) (YMD y 2 dom)]
|
||||
[(3) (YMD y 3 dom)]
|
||||
[(4) (YMD y 4 dom)]
|
||||
[(5) (YMD y 5 dom)]
|
||||
[(6) (YMD y 6 dom)]
|
||||
[(7) (YMD y 7 dom)]
|
||||
[(8) (YMD y 8 dom)]
|
||||
[(9) (YMD y 9 dom)]
|
||||
[(10) (YMD y 10 dom)]
|
||||
[(11) (YMD y 11 dom)]
|
||||
[(12) (YMD y 12 dom)]
|
||||
[else (error "jdn->ymd")]))))
|
||||
|
||||
|
||||
(: jdn->wday (-> Integer (U 0 1 2 3 4 5 6)))
|
||||
(define (jdn->wday jdn)
|
||||
(case (mod (add1 jdn) 7)
|
||||
[(0) 0]
|
||||
[(1) 1]
|
||||
[(2) 2]
|
||||
[(3) 3]
|
||||
[(4) 4]
|
||||
[(5) 5]
|
||||
[(6) 6]
|
||||
[else (error "jdn->wday")]))
|
||||
|
||||
(: jdn->iso-wday (-> Integer (U 1 2 3 4 5 6 7)))
|
||||
(define (jdn->iso-wday jdn)
|
||||
(case (mod1 (jdn->wday jdn) 7)
|
||||
[(1) 1]
|
||||
[(2) 2]
|
||||
[(3) 3]
|
||||
[(4) 4]
|
||||
[(5) 5]
|
||||
[(6) 6]
|
||||
[(7) 7]
|
||||
[else (error "jdn->iso-wday")]))
|
||||
|
||||
(: ymd->yday (-> YMD Natural));(integer-in 1 366)))
|
||||
(define (ymd->yday ymd)
|
||||
(match-define (YMD y m d) ymd)
|
||||
(+ d
|
||||
(if (leap-year? y)
|
||||
(vector-ref CUMULATIVE-MONTH-DAYS/LEAP (sub1 m))
|
||||
(vector-ref CUMULATIVE-MONTH-DAYS (sub1 m)))))
|
||||
|
||||
(: ymd->quarter (-> YMD (U 1 2 3 4)));(integer-in 1 4)))
|
||||
(define (ymd->quarter ymd)
|
||||
(case (add1 (quotient (sub1 (YMD-m ymd)) 3))
|
||||
[(1) 1]
|
||||
[(2) 2]
|
||||
[(3) 3]
|
||||
[(4) 4]
|
||||
[else (error "ymd->quarter")]))
|
||||
|
||||
(: ymd-add-years (-> YMD Natural YMD))
|
||||
(define (ymd-add-years ymd n)
|
||||
(match-define (YMD y m d) ymd)
|
||||
(define ny (+ y n))
|
||||
(define max-dom (days-in-month ny m))
|
||||
(YMD ny m (if (<= d max-dom) d max-dom)))
|
||||
|
||||
(: ymd-add-months (-> YMD Natural YMD))
|
||||
(define (ymd-add-months ymd n)
|
||||
(match-define (YMD y m d) ymd)
|
||||
(: ny Natural)
|
||||
(define ny
|
||||
(let ([r (+ y (div (+ m n -1) 12))]) (unless (index? r) (error "ymd-add-months")) r))
|
||||
(: nm Month)
|
||||
(define nm
|
||||
(case (let ([v (mod1 (+ m n) 12)])
|
||||
(if (< v 0)
|
||||
(+ 12 v)
|
||||
v))
|
||||
[(1) 1]
|
||||
[(2) 2]
|
||||
[(3) 3]
|
||||
[(4) 4]
|
||||
[(5) 5]
|
||||
[(6) 6]
|
||||
[(7) 7]
|
||||
[(8) 8]
|
||||
[(9) 9]
|
||||
[(10) 10]
|
||||
[(11) 11]
|
||||
[(12) 12]
|
||||
[else (error "ymd-add-months")]))
|
||||
(define max-dom (days-in-month ny nm))
|
||||
(define nd (if (<= d max-dom) d max-dom))
|
||||
(unless (index? nd)
|
||||
(error "ymd-add-months"))
|
||||
(case nm
|
||||
[(1) (YMD ny 1 nd)]
|
||||
[(2) (YMD ny 2 nd)]
|
||||
[(3) (YMD ny 3 nd)]
|
||||
[(4) (YMD ny 4 nd)]
|
||||
[(5) (YMD ny 5 nd)]
|
||||
[(6) (YMD ny 6 nd)]
|
||||
[(7) (YMD ny 7 nd)]
|
||||
[(8) (YMD ny 8 nd)]
|
||||
[(9) (YMD ny 9 nd)]
|
||||
[(10) (YMD ny 10 nd)]
|
||||
[(11) (YMD ny 11 nd)]
|
||||
[(12) (YMD ny 12 nd)]
|
||||
[else (error "ymd-add-months")]))
|
||||
|
||||
|
||||
(: leap-year? (-> Natural Boolean))
|
||||
(define (leap-year? y)
|
||||
(and (zero? (remainder y 4))
|
||||
(or (not (zero? (remainder y 100)))
|
||||
(zero? (remainder y 400)))))
|
||||
|
||||
(: days-in-month (-> Natural
|
||||
Month
|
||||
(U 28 29 30 31)))
|
||||
(define (days-in-month y m)
|
||||
(let ([delta (if (and (= m 2)
|
||||
(leap-year? y))
|
||||
1
|
||||
0)])
|
||||
(case (+ (vector-ref DAYS-PER-MONTH m) delta)
|
||||
[(28) 28]
|
||||
[(29) 29]
|
||||
[(30) 30]
|
||||
[(31) 31]
|
||||
[else (error "days in month")])))
|
||||
|
||||
;; (define (day-of-month/c y m)
|
||||
;; (integer-in 1 (days-in-month y m)))
|
||||
|
||||
(: iso-weeks-in-year (-> Natural (U 52 53)))
|
||||
(define (iso-weeks-in-year y)
|
||||
(define w (jdn->wday (ymd->jdn (YMD y 1 1))))
|
||||
|
||||
(cond [(or (= w 4)
|
||||
(and (leap-year? y) (= w 3)))
|
||||
53]
|
||||
[else
|
||||
52]))
|
||||
|
||||
(: DAYS-PER-MONTH (Vector 0 31 28 31 30 31 30 31 31 30 31 30 31))
|
||||
(define DAYS-PER-MONTH
|
||||
(vector 0 31 28 31 30 31 30 31 31 30 31 30 31))
|
||||
|
||||
(: CUMULATIVE-MONTH-DAYS (Vector 0 31 59 90 120 151 181 212 243 273 304 334))
|
||||
(define CUMULATIVE-MONTH-DAYS
|
||||
(vector 0 31 59 90 120 151 181 212 243 273 304 334))
|
||||
|
||||
(: CUMULATIVE-MONTH-DAYS/LEAP (Vector 0 31 60 91 121 152 182 213 244 274 305 335))
|
||||
(define CUMULATIVE-MONTH-DAYS/LEAP
|
||||
(vector 0 31 60 91 121 152 182 213 244 274 305 335))
|
|
@ -1,78 +0,0 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
;; Front-end:
|
||||
;; Working with current clock
|
||||
|
||||
(provide;/contract
|
||||
current-clock ;any/c]
|
||||
current-posix-seconds ;any/c]
|
||||
now/moment ;(->i () (#:tz [tz tz/c]) [res moment?])]
|
||||
now ;(->i () (#:tz [tz tz/c]) [res datetime?])]
|
||||
today ;(->i () (#:tz [tz tz/c]) [res date?])]
|
||||
current-time ;(->i () (#:tz [tz tz/c]) [res time?])]
|
||||
now/moment/utc ;(-> moment?)]
|
||||
now/utc ;(-> datetime?)]
|
||||
today/utc ;(-> date?)]
|
||||
current-time/utc ;(-> time?)])
|
||||
)
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
|
||||
(require
|
||||
(only-in racket/math exact-round)
|
||||
"../base/types.rkt"
|
||||
"tzinfo-adapter.rkt"
|
||||
"gregor-adapter.rkt"
|
||||
)
|
||||
(require "moment.rkt"
|
||||
)
|
||||
(require "datetime.rkt"
|
||||
)
|
||||
|
||||
;; =============================================================================
|
||||
|
||||
(: now/moment (->* () (#:tz (U tz #f)) Moment))
|
||||
(define (now/moment #:tz [tz (current-timezone)])
|
||||
(unless tz (error "current-timezone is #f"))
|
||||
(posix->moment ((current-clock)) tz))
|
||||
|
||||
(: now/moment/utc (-> Moment))
|
||||
(define (now/moment/utc)
|
||||
(now/moment #:tz "Etc/UTC"))
|
||||
|
||||
(: now (->* () (#:tz (U tz #f)) DateTime))
|
||||
(define (now #:tz [tz (current-timezone)])
|
||||
(unless tz (error "now: current-timezone is #f"))
|
||||
(moment->datetime/local (now/moment #:tz tz)))
|
||||
|
||||
(: now/utc (-> DateTime))
|
||||
(define (now/utc)
|
||||
(now #:tz "Etc/UTC"))
|
||||
|
||||
(: today (->* () (#:tz (U tz #f)) Date))
|
||||
(define (today #:tz [tz (current-timezone)])
|
||||
(unless tz (error "today: current-timezone is #f"))
|
||||
(datetime->date (now #:tz tz)))
|
||||
|
||||
(: today/utc (-> Date))
|
||||
(define (today/utc)
|
||||
(today #:tz "Etc/UTC"))
|
||||
|
||||
(: current-time (->* () (#:tz (U tz #f)) Time))
|
||||
(define (current-time #:tz [tz (current-timezone)])
|
||||
(unless tz (error "current-time: current-timezone is #f"))
|
||||
(datetime->time (now #:tz tz)))
|
||||
|
||||
(: current-time/utc (-> Time))
|
||||
(define (current-time/utc)
|
||||
(current-time #:tz "Etc/UTC"))
|
||||
|
||||
(: current-posix-seconds (-> Natural))
|
||||
(define (current-posix-seconds)
|
||||
(let ([r (exact-round (/ (inexact->exact (current-inexact-milliseconds)) 1000))])
|
||||
(unless (index? r) (error "current-posix-seconds"))
|
||||
r))
|
||||
|
||||
(: current-clock (Parameterof (-> Exact-Rational)))
|
||||
(define current-clock (make-parameter current-posix-seconds))
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user