Time

All functions are located in the com.biffweb namespace.

(now)
Same as (java.util.Date.)
Same as "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", for use with parse-date and format-date.

parse-date

View source
(parse-date date & [format])
Parses date (a string) using java.text.SimpleDateFormat.

If format isn't provided, uses rfc3339.

format-date

View source
(format-date date & [format])
Formats date using java.text.SimpleDateFormat.

If format isn't provided, uses rfc3339.

crop-date

View source
(crop-date date format)
Passes date through format-date and parse-date, in order to remove any
information not captured in the format.

For example:
(crop-date #inst "2022-03-27T09:13:34.182-00:00" "yyyy")
=> #inst "2022-01-01T08:00:00.000-00:00"

crop-day

View source
(crop-day date)
Same as (crop-date "yyyy-MM-dd")

elapsed?

View source
(elapsed? t1 t2 x unit)
Returns true if t2 occurs at least x units after t1.

unit can be :seconds, :minutes, :hours, :days, or :weeks.

between-hours?

View source
(between-hours? t h1 h2)
Returns true if t is between the hours of h1 and h2 UTC.

For example:
(between-hours? #inst "2022-03-27T14:18:34.360-00:00" 14 16)
=> true

add-seconds

View source
(add-seconds date seconds)
Returns a new java.util.Date with the given number of seconds added.
Have a question? Join the #biff channel on Clojurians Slack, or ask on GitHub.

Sign up for Biff: The Newsletter
Announcements, blog posts, et cetera et cetera.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.