blob: 530be4d7c23fe90118ea928cc15f0ae1427685b7 (
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
|
... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
(.require
[library
[lux (.except)
[abstract
[monad (.only do)]]
[control
["<>" parser (.only)]]
[data
["[0]" text
["%" \\format]
["<[1]>" \\parser (.only Parser)]]]
[math
[number
["n" nat]]]
[world
["[0]" time]]]]
["[0]" //
["[1]" date]])
(type .public Time
time.Time)
(def .public (format value)
(%.Format Time)
(let [(open "_[0]") (time.clock value)]
(%.format (//.pad _#hour)
(//.pad _#minute)
(//.pad _#second))))
(def .public parser
(<text>.Parser Time)
(do <>.monad
[hour (<>.codec n.decimal (<text>.exactly 2 <text>.decimal))
minute (<>.codec n.decimal (<text>.exactly 2 <text>.decimal))
second (<>.codec n.decimal (<text>.exactly 2 <text>.decimal))]
(<>.of_try (time.time
[time.#hour hour
time.#minute minute
time.#second second
time.#milli_second 0]))))
|