Time-related Utility Functions
This namespace contains utility functions for working with time objects, built on java.time.Instant (timestamps) and java.time.Duration (periods).
Time-related Utility Functions This namespace contains utility functions for working with time objects, built on java.time.Instant (timestamps) and java.time.Duration (periods).
(attempt-date-time-parse formatter timestamp-str)Inputs: [formatter :- DateTimeFormatter timestamp-str :- String]
Parses timestamp-str using formatter. Returns nil if parsing fails.
Inputs: [formatter :- DateTimeFormatter timestamp-str :- String] Parses `timestamp-str` using `formatter`. Returns nil if parsing fails.
(date-time year month day)(date-time year month day hour)(date-time year month day hour minute)(date-time year month day hour minute second)(date-time year month day hour minute second millis)Construct an Instant from year/month/day/hour/minute/second/millis (all UTC).
Construct an Instant from year/month/day/hour/minute/second/millis (all UTC).
(ephemeral-now-ns)Returns the current time as signed integer nanoseconds with respect to some ephemeral time line. Values are only comparable within the same process, and the range of values may be limited, but differences between successive calls within no more than 250 years of each other will be correct.
Returns the current time as *signed* integer nanoseconds with respect to some ephemeral time line. Values are only comparable within the same process, and the range of values may be limited, but differences between successive calls within no more than 250 years of each other will be correct.
(format-period p)Convert a Duration into a human-readable String, e.g. '2 minutes'. Normalizes to the largest clean unit.
Convert a Duration into a human-readable String, e.g. '2 minutes'. Normalizes to the largest clean unit.
(interval start end)Returns the Duration between two Instants.
Returns the Duration between two Instants.
(parse-iso-z s)Returns a pdb instant (UTC timestamp) if s represents an ISO formatted timestamp like "2011-12-03T10:15:30Z" or nil.
Returns a pdb instant (UTC timestamp) if s represents an ISO formatted timestamp like "2011-12-03T10:15:30Z" or nil.
Returns a pdb instant (UTC timestamp) if s represents an ISO formatted timestamp with offset like "2011-12-03T10:15:30+01:00" or nil.
Returns a pdb instant (UTC timestamp) if s represents an ISO formatted timestamp with offset like "2011-12-03T10:15:30+01:00" or nil.
(parse-period s)Parse a String into a Duration. Supported suffixes: d, h, m, s, ms. For example, (parse-period "2d") returns a Duration of 2 days.
Parse a String into a Duration. Supported suffixes: d, h, m, s, ms. For example, (parse-period "2d") returns a Duration of 2 days.
(period-longer? d1 d2)Returns true if d1 is longer than d2.
Returns true if d1 is longer than d2.
(periods-equal? _p)(periods-equal? p1 p2)(periods-equal? p1 p2 & more)Returns true if all given Durations represent the same amount of time.
Returns true if all given Durations represent the same amount of time.
(to-date-time x)Coerce x to an Instant. Accepts strings, longs, java.sql.Timestamps, and Instants.
Coerce x to an Instant. Accepts strings, longs, java.sql.Timestamps, and Instants.
(to-long t)Convert a timestamp to epoch milliseconds.
Convert a timestamp to epoch milliseconds.
(to-string t)Convert a timestamp to ISO-8601 string with mandatory millisecond precision. Accepts Instant, java.sql.Timestamp, or String (parsed and reformatted to normalize timezone offset and precision).
Convert a timestamp to ISO-8601 string with mandatory millisecond precision. Accepts Instant, java.sql.Timestamp, or String (parsed and reformatted to normalize timezone offset and precision).
(to-timestamp ts)Inputs: [ts] Returns: (s/maybe java.sql.Timestamp)
Convert to a java.sql.Timestamp. When ts is a String, attempts
parsing with likely date formats first.
Inputs: [ts] Returns: (s/maybe java.sql.Timestamp) Convert to a java.sql.Timestamp. When `ts` is a String, attempts parsing with likely date formats first.
(to-java-date x)Converts x to a java.util.Date.
Converts x to a java.util.Date.
(truncate-to-day t)Truncate an Instant to the start of the day (UTC).
Truncate an Instant to the start of the day (UTC).
(wire-datetime->instant s)Parses s as a PuppetDB wire format <datetime> and returns an Instant, or nil if the string cannot be parsed.
Parses s as a PuppetDB wire format <datetime> and returns an Instant, or nil if the string cannot be parsed.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |