framed.std.time

Date/time utilities on top of JodaTime/clj-time and goog.date/cljs-time

at-midnight

(at-midnight date)
Return the DateTime at midnight of a given date

datetime->unix

(datetime->unix date)
Convert a DateTime to a Unix timestamp (in seconds)

days-in

(days-in interval)
Return a sequence of all days in an interval (left-inclusive, right exclusive)
Ex:
  (std.time/days-in
    (clj-time.core/interval (clj-time.core/date-time 2015 8 20)
                            (clj-time.core/date-time 2015 8 23)))
  ; => [#<DateTime 2015-08-20> #<DateTime 2015-08-21> #<DateTime 2015-08-23>]

period-interval

(period-interval date period n)(period-interval date period n0 n1)
Given a period (e.g. 7 days), return the interval that is N
periods from date. Period must be a clj(s)-time period,
ex: (clj-time.core/days 7)

Zero denotes the interval starting from `date` and ending
one period later.

Ex:
  ; One 7-day period earlier than date
  (period-interval
    (clj-time.core/date-time 2014 11 13)
    (clj-time.core/days 7)
    -1)
  ; => #<Interval 2014-11-06 / 2014-11-13>

periods-from

(periods-from date period n)
Given a starting date, return the date that is N periods from it
N - positive or negative integer

Ex:
  (def start (clj-time.core/date-time 2015 2 20))
  (periods-from start (clj-time.core/days 2) -3)
  ; => #<DateTime 2015-02-14> ; Three two-day periods earlier

  (periods-from start (clj-time.core/days 2) 3)
  ; => #<DateTime 2015-02-26> ; Three two-day periods later

str->inst

Parse a string timestamp into a java.util.Date or goog.date.Date

unix->datetime

(unix->datetime t)
Return a DateTime from a Unix timestamp (in seconds)