1
0
mirror of https://github.com/janet-lang/janet synced 2025-10-15 07:47:40 +00:00

add os/mktime, an inverse to os/date.

This commit is contained in:
Leah Neukirchen
2020-03-18 19:52:25 +01:00
parent efdb13f0c7
commit 3ee43c3abb
2 changed files with 94 additions and 0 deletions

View File

@@ -226,6 +226,23 @@
:week-day 3}
(os/date 1388608200)) "os/date")
# OS mktime test
(assert (= 1388608200 (os/mktime {:year-day 0
:minutes 30
:month 0
:dst false
:seconds 0
:year 2014
:month-day 0
:hours 20
:week-day 3})) "os/mktime")
(def now (os/time))
(assert (= (os/mktime (os/date now)) now) "UTC os/mktime")
(assert (= (os/mktime (os/date now true) true) now) "local os/mktime")
(assert (= (os/mktime {:year 1970}) 0) "os/mktime default values")
# Appending buffer to self
(with-dyns [:out @""]