aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--date/init.janet7
-rw-r--r--test/02-api.janet14
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))