blob: efd33ca0a57fd810339e251edf419f147c5e53aa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
(.using
[library
[lux "*"
["[0]" time]
[abstract
[equivalence {"+" Equivalence}]
[monad {"+" do}]]
[control
["[0]" try {"+" Try}]
["<>" parser
["<[0]>" text {"+" Parser}]]]
[data
["[0]" product]
[text
["%" format {"+" Format}]]]
[time
["[0]" instant {"+" Instant}]]]]
["[0]" / "_"
["[1][0]" date]
["[1][0]" time]])
(type: .public Time
[/date.Date /time.Time])
(def: .public epoch
Time
[/date.epoch time.midnight])
(def: .public (instant time)
(-> Time Instant)
(let [[date time] time]
(instant.of_date_time (/date.value date)
time)))
(def: .public (of_instant instant)
(-> Instant (Try Time))
(do try.monad
[date (/date.date (instant.date instant))]
(in [date
(instant.time instant)])))
(def: .public equivalence
(Equivalence Time)
(product.equivalence /date.equivalence
time.equivalence))
(def: .public (format [date time])
(Format Time)
(%.format (/date.format date)
(/time.format time)))
(def: .public parser
(Parser Time)
(do <>.monad
[date /date.parser
time /time.parser]
(in [date time])))
|