diff options
| author | 2023-06-02 19:40:19 +0200 | |
|---|---|---|
| committer | 2023-06-02 19:40:19 +0200 | |
| commit | 169ac987af12c4989aef7499b65be749d928ffc0 (patch) | |
| tree | 49c16c23f8ae760f8bbd1536fc514d60a9943d87 | |
| parent | improve explanation of rfc3339 and co (diff) | |
finalize api draft 1, add tests
| -rw-r--r-- | date/init.janet | 7 | ||||
| -rw-r--r-- | test/02-api.janet | 14 |
2 files changed, 17 insertions, 4 deletions
diff --git a/date/init.janet b/date/init.janet index cd47c4f..858ef79 100644 --- a/date/init.janet +++ b/date/init.janet @@ -55,7 +55,7 @@ (:timegm! newtm)) # timegm! is slightly more efficient and we're discarding it (defn update-time* - `Variant of update-time that takes a dictionary.` + `Variant of update-time that takes a dictionary without normalizing it.` [time ds] (assert (dictionary? ds)) (update-time! time (fn [tm] @@ -73,8 +73,6 @@ it will be used as-is. Note that the resulting values need not be in any given range, as they will be normalized. - It will automatically re-determine if DST is applicable and give you back a - modified date/time object. If you need additional control over the underlying gmtime tm call, use `update-time*` or `update-time!`. @@ -94,4 +92,5 @@ :mday month-day :mon month :year year - :isdst :detect})) + # UTC only + :isdst false})) diff --git a/test/02-api.janet b/test/02-api.janet new file mode 100644 index 0000000..f759105 --- /dev/null +++ b/test/02-api.janet @@ -0,0 +1,14 @@ +(import ../date) + +(def now (date/time)) +(assert (date/time? now)) + +(def gmt (:gmtime now)) +(def loc (:localtime now)) +(assert (date/tm? gmt)) +(assert (date/tm? loc)) +(assert (= (:mktime loc) (:timegm gmt))) + +(def before (date/update-time* now {:sec -1 :min dec})) +(def after (date/update-time* now {:sec 61 :min inc})) +(assert (> after now before)) |
