Login
7 branches 0 tags
Benjamin Vincent Schulenburg Fixed *module* not being bound for fs modules 8f4a5ef 3 years ago 874 Commits
nujel / stdlib_modules / time.nuj
;;; Nujel - Copyright (C) 2020-2021 - Benjamin Vincent Schulenburg
;;; This project uses the MIT license, a copy should be included under /LICENSE
;;;
;;; Time related λs

[export seconds [defn seconds [timestamp]
      "Return the seconds part of TIMESTAMP, defaults to current time"
      [rem [or timestamp [time]] 60]]]

[export minutes [defn minutes [timestamp]
      "Return the minutes part of TIMESTAMP, defaults to current time"
      [rem [div/int [or timestamp [time]] 60] 60]]]

[export hours [defn hours [timestamp]
      "Return the hours part of TIMESTAMP, defaults to current time"
      [rem [div/int [or timestamp [time]] 3600] 24]]]

[deftest 34 [time/seconds 1637755714]]
[deftest  8 [time/minutes 1637755714]]
[deftest 12 [time/hours   1637755714]]
[deftest 59 [time/seconds 1637755739]]
[deftest  0 [time/seconds 1637755740]]