diff options
author | Eduardo Julian | 2021-01-03 07:48:12 -0400 |
---|---|---|
committer | Eduardo Julian | 2021-01-03 07:48:12 -0400 |
commit | c03bd9f9787fb9f383c57b4ebb0fa9d49abbfaa1 (patch) | |
tree | 68a7f2f043eff00492ffe2b5e442bae98167a873 /stdlib/source/program/aedifex/artifact/time_stamp/time.lux | |
parent | 02d27daeacac74785c2b0f4d1ce03d432377a36e (diff) |
Place the "program:" macro of "lux/control/parser/cli" in its own module.
Diffstat (limited to 'stdlib/source/program/aedifex/artifact/time_stamp/time.lux')
-rw-r--r-- | stdlib/source/program/aedifex/artifact/time_stamp/time.lux | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/stdlib/source/program/aedifex/artifact/time_stamp/time.lux b/stdlib/source/program/aedifex/artifact/time_stamp/time.lux new file mode 100644 index 000000000..d14f0a435 --- /dev/null +++ b/stdlib/source/program/aedifex/artifact/time_stamp/time.lux @@ -0,0 +1,35 @@ +(.module: + [lux #* + ["." time (#+ Time)] + [abstract + [monad (#+ do)]] + [control + ["<>" parser + ["<.>" text (#+ Parser)]]] + [data + [text + ["%" format]]] + [math + [number + ["n" nat]]]] + ["." // #_ + ["#" date]]) + +(def: #export (format value) + (%.Format Time) + (let [(^slots [#time.hour #time.minute #time.second]) (time.clock value)] + (%.format (//.pad hour) + (//.pad minute) + (//.pad second)))) + +(def: #export 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))] + (<>.lift (time.time + {#time.hour hour + #time.minute minute + #time.second second + #time.milli_second 0})))) |