-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds more date helpers and fixes cljs require bug
- Loading branch information
Showing
4 changed files
with
42 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
(ns serverless.core.async | ||
(:require [cljs.core.async]) | ||
(:require-macros [serverless.core.async])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,36 @@ | ||
(ns serverless.date) | ||
|
||
(defn now [] | ||
(defn now | ||
"Milliseconds since epoch (now)" | ||
[] | ||
(js-invoke js/Date "now")) | ||
|
||
(defn ->iso-str | ||
"Converts datetime object into ISO string" | ||
[datetime-obj] | ||
(js-invoke (new js/Date datetime-obj) "toISOString")) | ||
|
||
(defn now-iso-str | ||
"Now ISO string" | ||
[] | ||
(->iso-str (now))) | ||
|
||
(defn ->timestamp | ||
"Converts any format-table js datetime object to milliseconds from epoch" | ||
[datetime-object] | ||
(js-invoke (new js/Date datetime-object) "getTime")) | ||
|
||
(defn before? | ||
"t1 is before t2" | ||
[t1 t2] | ||
(< (->timestamp t1) (->timestamp t2))) | ||
|
||
(defn after? | ||
"t1 is after t2" | ||
[t1 t2] | ||
(> (->timestamp t1) (->timestamp t2))) | ||
|
||
(defn equal? | ||
"t1 is equal to t2" | ||
[t1 t2] | ||
(= (->timestamp t1) (->timestamp t2))) |