Login
7 branches 0 tags
Ben (X13/Arch) Improved indentation and added [defun] macro dfbe349 4 years ago 154 Commits
nujel / stdlib / time.nuj
; Time related λs

[def time/seconds [λ [timestamp]
        "Return the seconds part of TIMESTAMP, defaults to current time"
        [% [default timestamp [time]] 60]
]]

[def time/minutes [λ [timestamp]
        "Return the minutes part of TIMESTAMP, defaults to current time"
        [% [/ [default timestamp [time]] 60] 60]
]]

[def time/hours [λ [timestamp]
        "Return the hours part of TIMESTAMP, defaults to current time"
        [% [/ [default timestamp [time]] 3600] 24]
]]

[def profile [λ [@...body]
        [def form [cons 'do @...body]]
        [def start-time [time/milliseconds]]
        [def val [eval form]]
        [def end-time [time/milliseconds]]
        [display [cat "Evaluating " [str/write form] " to " [str/write val] " took " [- end-time start-time] " milliseconds."]]
]]