From 71de092a045dc70ab1c9eead477cf1512b144a87 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 12 Jan 2021 23:09:05 -0400 Subject: Raise error when trying to use deprecated fields/method/classes in JVM. --- stdlib/source/program/aedifex/artifact/time.lux | 35 +++++++++++++++++++ .../source/program/aedifex/artifact/time/date.lux | 39 ++++++++++++++++++++++ .../source/program/aedifex/artifact/time/time.lux | 35 +++++++++++++++++++ .../program/aedifex/artifact/time_stamp/date.lux | 39 ---------------------- .../program/aedifex/artifact/time_stamp/time.lux | 35 ------------------- 5 files changed, 109 insertions(+), 74 deletions(-) create mode 100644 stdlib/source/program/aedifex/artifact/time.lux create mode 100644 stdlib/source/program/aedifex/artifact/time/date.lux create mode 100644 stdlib/source/program/aedifex/artifact/time/time.lux delete mode 100644 stdlib/source/program/aedifex/artifact/time_stamp/date.lux delete mode 100644 stdlib/source/program/aedifex/artifact/time_stamp/time.lux (limited to 'stdlib/source/program/aedifex/artifact') diff --git a/stdlib/source/program/aedifex/artifact/time.lux b/stdlib/source/program/aedifex/artifact/time.lux new file mode 100644 index 000000000..19eb417a5 --- /dev/null +++ b/stdlib/source/program/aedifex/artifact/time.lux @@ -0,0 +1,35 @@ +(.module: + [lux #* + [abstract + [equivalence (#+ Equivalence)] + [monad (#+ do)]] + [control + ["<>" parser + ["<.>" text (#+ Parser)]]] + [data + [text + ["%" format (#+ Format)]]] + [time + ["." instant (#+ Instant)]]] + ["." / #_ + ["#." date] + ["#." time]]) + +(type: #export Time + Instant) + +(def: #export equivalence + (Equivalence Time) + instant.equivalence) + +(def: #export (format value) + (Format Time) + (%.format (/date.format (instant.date value)) + (/time.format (instant.time value)))) + +(def: #export parser + (Parser Time) + (do <>.monad + [date /date.parser + time /time.parser] + (wrap (instant.from_date_time date time)))) diff --git a/stdlib/source/program/aedifex/artifact/time/date.lux b/stdlib/source/program/aedifex/artifact/time/date.lux new file mode 100644 index 000000000..18df2900b --- /dev/null +++ b/stdlib/source/program/aedifex/artifact/time/date.lux @@ -0,0 +1,39 @@ +(.module: + [lux #* + [abstract + [monad (#+ do)]] + [control + ["<>" parser + ["<.>" text (#+ Parser)]]] + [data + [text + ["%" format]]] + [math + [number + ["n" nat]]] + [time + ["." date (#+ Date)] + ["." year] + ["." month]]]) + +(def: #export (pad value) + (-> Nat Text) + (if (n.< 10 value) + (%.format "0" (%.nat value)) + (%.nat value))) + +(def: #export (format value) + (%.Format Date) + (%.format (|> value date.year year.value .nat %.nat) + (|> value date.month month.number ..pad) + (|> value date.day_of_month ..pad))) + +(def: #export parser + (Parser Date) + (do <>.monad + [year (<>.codec n.decimal (.exactly 4 .decimal)) + year (<>.lift (year.year (.int year))) + month (<>.codec n.decimal (.exactly 2 .decimal)) + month (<>.lift (month.by_number month)) + day_of_month (<>.codec n.decimal (.exactly 2 .decimal))] + (<>.lift (date.date year month day_of_month)))) diff --git a/stdlib/source/program/aedifex/artifact/time/time.lux b/stdlib/source/program/aedifex/artifact/time/time.lux new file mode 100644 index 000000000..d14f0a435 --- /dev/null +++ b/stdlib/source/program/aedifex/artifact/time/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 + (.Parser Time) + (do <>.monad + [hour (<>.codec n.decimal (.exactly 2 .decimal)) + minute (<>.codec n.decimal (.exactly 2 .decimal)) + second (<>.codec n.decimal (.exactly 2 .decimal))] + (<>.lift (time.time + {#time.hour hour + #time.minute minute + #time.second second + #time.milli_second 0})))) diff --git a/stdlib/source/program/aedifex/artifact/time_stamp/date.lux b/stdlib/source/program/aedifex/artifact/time_stamp/date.lux deleted file mode 100644 index 18df2900b..000000000 --- a/stdlib/source/program/aedifex/artifact/time_stamp/date.lux +++ /dev/null @@ -1,39 +0,0 @@ -(.module: - [lux #* - [abstract - [monad (#+ do)]] - [control - ["<>" parser - ["<.>" text (#+ Parser)]]] - [data - [text - ["%" format]]] - [math - [number - ["n" nat]]] - [time - ["." date (#+ Date)] - ["." year] - ["." month]]]) - -(def: #export (pad value) - (-> Nat Text) - (if (n.< 10 value) - (%.format "0" (%.nat value)) - (%.nat value))) - -(def: #export (format value) - (%.Format Date) - (%.format (|> value date.year year.value .nat %.nat) - (|> value date.month month.number ..pad) - (|> value date.day_of_month ..pad))) - -(def: #export parser - (Parser Date) - (do <>.monad - [year (<>.codec n.decimal (.exactly 4 .decimal)) - year (<>.lift (year.year (.int year))) - month (<>.codec n.decimal (.exactly 2 .decimal)) - month (<>.lift (month.by_number month)) - day_of_month (<>.codec n.decimal (.exactly 2 .decimal))] - (<>.lift (date.date year month day_of_month)))) diff --git a/stdlib/source/program/aedifex/artifact/time_stamp/time.lux b/stdlib/source/program/aedifex/artifact/time_stamp/time.lux deleted file mode 100644 index d14f0a435..000000000 --- a/stdlib/source/program/aedifex/artifact/time_stamp/time.lux +++ /dev/null @@ -1,35 +0,0 @@ -(.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 - (.Parser Time) - (do <>.monad - [hour (<>.codec n.decimal (.exactly 2 .decimal)) - minute (<>.codec n.decimal (.exactly 2 .decimal)) - second (<>.codec n.decimal (.exactly 2 .decimal))] - (<>.lift (time.time - {#time.hour hour - #time.minute minute - #time.second second - #time.milli_second 0})))) -- cgit v1.2.3