Liking cljdoc? Tell your friends :D

tupelo.java-time


*zone-id*clj


->field-strsclj

(->field-strs temporal)

Inputs: [temporal :- Temporal] Returns: #:s{Keyword s/Str}

Given an Temporal value, returns a map with string values for the component fields.

(->field-strs (Instant/parse '2037-07-14t01:02:03.012345678Z')) =>
  {:year-4   '2037'
   :year-2   '37'
   :month-2  '07'
   :day-2    '14'
   :hour-2   '01'
   :min-2    '02'
   :sec-2    '03'
   :micros-6 '012345'
   :millis-3 '012'
   :nanos-9  '012345678'
   }
Inputs: [temporal :- Temporal]
Returns: #:s{Keyword s/Str}

Given an Temporal value, returns a map with string values for the component fields.

    (->field-strs (Instant/parse '2037-07-14t01:02:03.012345678Z')) =>
      {:year-4   '2037'
       :year-2   '37'
       :month-2  '07'
       :day-2    '14'
       :hour-2   '01'
       :min-2    '02'
       :sec-2    '03'
       :micros-6 '012345'
       :millis-3 '012'
       :nanos-9  '012345678'
       }
 
raw docstring

->Instantclj

(->Instant arg)

Coerces an Instant, ZonedDateTime, or org.joda.time.ReadableInstant => Instant

Coerces an Instant, ZonedDateTime, or org.joda.time.ReadableInstant => Instant 
raw docstring

->LocalDateclj

(->LocalDate arg)

Inputs: [arg] Returns: LocalDate

Inputs: [arg]
Returns: LocalDate
raw docstring

->str-HHMMSSclj

(->str-HHMMSS temporal)

Inputs: [temporal :- Temporal] Returns: s/Str

Given an Instant like '2037-07-14t11:22:33.123456789Z', returns a string with the HHMMSS format like '112233'

Inputs: [temporal :- Temporal]
Returns: s/Str

Given an Instant like '2037-07-14t11:22:33.123456789Z', returns a string with the
HHMMSS format like '112233' 
raw docstring

->str-isoclj

(->str-iso temporal)

Inputs: [temporal :- Temporal] Returns: s/Str

Given an Instant or ZonedDateTime, returns a ISO 8601 datetime string like 2018-09-05T23:05:19.123Z

Inputs: [temporal :- Temporal]
Returns: s/Str

Given an Instant or ZonedDateTime, returns a ISO 8601 datetime string like `2018-09-05T23:05:19.123Z`
raw docstring

->str-iso-niceclj

(->str-iso-nice temporal)

Inputs: [temporal :- Temporal] Returns: s/Str

Given an Instant or ZonedDateTime, returns an ISO date-time string like 2018-09-05 23:05:19.123Z (with a space instead of T)

Inputs: [temporal :- Temporal]
Returns: s/Str

Given an Instant or ZonedDateTime, returns an ISO date-time string like
`2018-09-05 23:05:19.123Z` (with a space instead of `T`)
raw docstring

->str-YYYY-MM-DDclj

(->str-YYYY-MM-DD temporal)

Inputs: [temporal :- Temporal] Returns: s/Str

Given an Instant or ZonedDateTime, returns a string like 2018-09-05

Inputs: [temporal :- Temporal]
Returns: s/Str

Given an Instant or ZonedDateTime, returns a string like `2018-09-05`
raw docstring

->str-YYYYMMDDclj

(->str-YYYYMMDD temporal)

Inputs: [temporal :- Temporal] Returns: s/Str

Given an Instant or ZonedDateTime, returns a compact date-time string like 2018-09-05 23:05:19.123Z => 20180905

Inputs: [temporal :- Temporal]
Returns: s/Str

Given an Instant or ZonedDateTime, returns a compact date-time string like
  `2018-09-05 23:05:19.123Z` => `20180905` 
raw docstring

->str-YYYYMMDD-HHMMSSclj

(->str-YYYYMMDD-HHMMSS temporal)

Inputs: [temporal :- Temporal] Returns: s/Str

Given an Instant or ZonedDateTime, returns a compact date-time string like 2018-09-05 23:05:19.123Z => 20180905-230519

Inputs: [temporal :- Temporal]
Returns: s/Str

Given an Instant or ZonedDateTime, returns a compact date-time string like
`2018-09-05 23:05:19.123Z` => `20180905-230519` 
raw docstring

->year-quarterclj

(->year-quarter arg)

Inputs: [arg] Returns: tsk/Quarter

Given a date-ish value (e.g. LocalDate, et al), returns the quarter of the year as one of #{ :Q1 :Q2 :Q3 :Q4 }

Inputs: [arg]
Returns: tsk/Quarter

Given a date-ish value (e.g. LocalDate, et al), returns the quarter of the year
as one of #{ :Q1 :Q2 :Q3 :Q4 } 
raw docstring

->ZonedDateTimeclj

(->ZonedDateTime arg)

Coerces a org.joda.time.ReadableInstant to java.time.ZonedDateTime

Coerces a org.joda.time.ReadableInstant to java.time.ZonedDateTime
raw docstring

between->unitsclj

(between->units chrono-unit t1 t2)

Inputs: [chrono-unit :- ChronoUnit t1 :- Temporal t2 :- Temporal] Returns: s/Int

Returns the integer number of ChronoUnit values between two temporal values, truncating any fraction. Example:

  (let [i1      (->Instant "1987-11-22t01:30:00z")
        i2      (->Instant "1987-11-22t03:29:00z")
        delta   (between ChronoUnit/HOURS i1 i2) ]  ...)

yields delta=1 since 1hr 59min is truncated to 1 hour.

Inputs: [chrono-unit :- ChronoUnit t1 :- Temporal t2 :- Temporal]
Returns: s/Int

Returns the integer number of ChronoUnit values between two temporal values, truncating any fraction.
 Example:

      (let [i1      (->Instant "1987-11-22t01:30:00z")
            i2      (->Instant "1987-11-22t03:29:00z")
            delta   (between ChronoUnit/HOURS i1 i2) ]  ...)

yields delta=1 since 1hr 59min is truncated to 1 hour. 
raw docstring

fixed-point?clj

(fixed-point? it)

Returns true iff arg represents a fixed point in time. Examples:

[java.time ZonedDateTime Instant] [org.joda.time DateTime Instant ReadableInstant]

Returns true iff arg represents a fixed point in time. Examples:

[java.time       ZonedDateTime  Instant]
[org.joda.time        DateTime  Instant  ReadableInstant]
raw docstring

increasing-or-equal?clj

(increasing-or-equal? t1 t2 t3)

Inputs: [t1 :- IncreasingComparable t2 :- IncreasingComparable t3 :- IncreasingComparable] Returns: s/Bool

Returns true iff times [t1 t2 t3] is in strictly increasing order (closed interval)

Inputs: [t1 :- IncreasingComparable t2 :- IncreasingComparable t3 :- IncreasingComparable]
Returns: s/Bool

Returns true iff times [t1 t2 t3] is in strictly increasing order (closed interval)
raw docstring

increasing?clj

(increasing? t1 t2 t3)

Inputs: [t1 :- IncreasingComparable t2 :- IncreasingComparable t3 :- IncreasingComparable] Returns: s/Bool

Returns true iff times [t1 t2 t3] is in strictly increasing order (open interval)

Inputs: [t1 :- IncreasingComparable t2 :- IncreasingComparable t3 :- IncreasingComparable]
Returns: s/Bool

Returns true iff times [t1 t2 t3] is in strictly increasing order (open interval)
raw docstring

IncreasingComparableclj


Instant-str?clj

(Instant-str? s)

Inputs: [s :- s/Str] Returns: s/Bool

Returns true if string matches a Instant (ISO 8601) pattern like '1999-12-31T11:22:33Z'

Inputs: [s :- s/Str]
Returns: s/Bool

Returns true if string matches a Instant (ISO 8601) pattern like '1999-12-31T11:22:33Z' 
raw docstring

Instant?clj

(Instant? it)

Returns true iff arg is an instance of java.time.Instant

Returns true iff arg is an instance of java.time.Instant 
raw docstring

iso-str-nice-str?clj

(iso-str-nice-str? s)

Inputs: [s :- s/Str] Returns: s/Bool

Returns true if string matches a 'nice' ISO 8601 pattern like '1999-12-31 11:22:33Z'

Inputs: [s :- s/Str]
Returns: s/Bool

Returns true if string matches a 'nice' ISO 8601 pattern like '1999-12-31 11:22:33Z' 
raw docstring

joda-instant?clj

(joda-instant? it)

Returns true iff arg is an instance of org.joda.time.ReadableInstant

Returns true iff arg is an instance of org.joda.time.ReadableInstant 
raw docstring

LocalDate->tagvalclj

(LocalDate->tagval ld)

Inputs: [ld :- LocalDate] Returns: {:LocalDate s/Str}

Converts a java.time.LocalDate object to a tagval

Inputs: [ld :- LocalDate]
Returns: {:LocalDate s/Str}

Converts a java.time.LocalDate object to a tagval
raw docstring

LocalDate-interval->daysclj

(LocalDate-interval->days interval)

Inputs: [interval :- Interval] Returns: s/Int

Returns the duration in days from the start to the end of a LocalDate Interval

Inputs: [interval :- Interval]
Returns: s/Int

Returns the duration in days from the start to the end of a LocalDate Interval
raw docstring

LocalDate-str?clj

(LocalDate-str? s)

Inputs: [s :- s/Str] Returns: s/Bool

Returns true if string matches a LocalDate pattern like '1999-12-31'

Inputs: [s :- s/Str]
Returns: s/Bool

Returns true if string matches a LocalDate pattern like '1999-12-31' 
raw docstring

LocalDate?clj

(LocalDate? arg)

Inputs: [arg] Returns: s/Bool

Returns true iff arg is of type LocalDate

Inputs: [arg]
Returns: s/Bool

Returns true iff arg is of type LocalDate
raw docstring

localdates->day-idxsclj

(localdates->day-idxs ld-vals)

Inputs: [ld-vals :- [LocalDate]] Returns: [s/Int]

Converts a sequence of LocalDate objects into an integer series like [0 1 2 ...], relative to the first value. Assumes LocalDate's are in ascending order.

Inputs: [ld-vals :- [LocalDate]]
Returns: [s/Int]

Converts a sequence of LocalDate objects into an integer series like [0 1 2 ...], relative to the first value.
Assumes LocalDate's are in ascending order.
raw docstring

LocalDateTime-str?clj

(LocalDateTime-str? s)

Inputs: [s :- s/Str] Returns: s/Bool

Returns true if string matches a LocalDateTime pattern like '1999-12-31T11:22:33'

Inputs: [s :- s/Str]
Returns: s/Bool

Returns true if string matches a LocalDateTime pattern like '1999-12-31T11:22:33' 
raw docstring

millis->Instantclj

(millis->Instant millis)

Wrapper for java.time.Instant/ofEpochMilli

Wrapper for java.time.Instant/ofEpochMilli 
raw docstring

now->Dateclj

(now->Date)

Returns the current time as a java.util.Date

Returns the current time as a java.util.Date
raw docstring

now->Instantclj

(now->Instant)

Returns the current time as a java.lang.Instant

Returns the current time as a java.lang.Instant
raw docstring

now->ZonedDateTimeclj

(now->ZonedDateTime)

Returns the current time as a java.lang.ZonedDateTime (UTC)

Returns the current time as a java.lang.ZonedDateTime (UTC)
raw docstring

parse-iso-str->Instantclj

(parse-iso-str->Instant iso-datetime-str)

Inputs: [iso-datetime-str :- s/Str] Returns: Instant

Convert an ISO 8601 string to epoch milliseconds. Will collapse excess whitespace.

Inputs: [iso-datetime-str :- s/Str]
Returns: Instant

Convert an ISO 8601 string to epoch milliseconds. Will collapse excess whitespace.
raw docstring

parse-iso-str->millisclj

(parse-iso-str->millis iso-datetime-str)

Inputs: [iso-datetime-str :- s/Str] Returns: s/Int

Convert an ISO 8601 string to epoch milliseconds. Will collapse excess whitespace.

Inputs: [iso-datetime-str :- s/Str]
Returns: s/Int

Convert an ISO 8601 string to epoch milliseconds. Will collapse excess whitespace.
raw docstring

parse-iso-str->sql-timestampclj

(parse-iso-str->sql-timestamp iso-datetime-str)

Inputs: [iso-datetime-str :- s/Str]

Convert an ISO 8601 string to a java.sql.Timestamp

Inputs: [iso-datetime-str :- s/Str]

Convert an ISO 8601 string to a java.sql.Timestamp
raw docstring

parse-iso-str-nice->Instantclj

(parse-iso-str-nice->Instant iso-str)

Inputs: [iso-str :- s/Str] Returns: Instant

Parse a near-iso string like '2019-09-19 18:09:35Z' (it is missing the 'T' between the date & time fields) into an Instant. Will collapse excess whitespace.

Inputs: [iso-str :- s/Str]
Returns: Instant

Parse a near-iso string like '2019-09-19 18:09:35Z' (it is missing the 'T' between the
date & time fields) into an Instant. Will collapse excess whitespace.
raw docstring

parse-sql-timestamp-str->Instant-utcclj

(parse-sql-timestamp-str->Instant-utc sql-timestamp-str)

Inputs: [sql-timestamp-str :- s/Str] Returns: Instant

Parse a near-Timestamp string like ' 2019-09-19 18:09:35 ' (sloppy spacing) into an Instant. Assumes UTC timezone. Will collapse excess whitespace.

Inputs: [sql-timestamp-str :- s/Str]
Returns: Instant

Parse a near-Timestamp string like '  2019-09-19 18:09:35 ' (sloppy spacing) into an Instant.
Assumes UTC timezone. Will collapse excess whitespace.
raw docstring

Period?clj

(Period? it)

Returns true iff arg is an instance of Period.

Returns true iff arg is an instance of Period. 
raw docstring

previous-or-sameclj

(previous-or-same temporal tgt-dow)

Inputs: [temporal :- Temporal tgt-dow :- DayOfWeek] Returns: Temporal

Given a temporal value and a target such as DayOfWeek/SUNDAY, makes the minimal change to previous or same day of week. Example:

  (previous-or-same t DayOfWeek/SUNDAY)
Inputs: [temporal :- Temporal tgt-dow :- DayOfWeek]
Returns: Temporal

Given a temporal value and a target such as DayOfWeek/SUNDAY, makes the minimal
change to previous or same day of week. Example:

      (previous-or-same t DayOfWeek/SUNDAY)
raw docstring

pseudo-Temporalclj


same-instant?clj

(same-instant? & temporals)

Inputs: [& temporals :- [pseudo-Temporal]] Returns: s/Bool

Returns true iff two Instant/ZonedDateTime objects (or similar) represent the same instant of time, regardless of time zone. A thin wrapper over ZonedDateTime/isEqual

Inputs: [& temporals :- [pseudo-Temporal]]
Returns: s/Bool

Returns true iff two Instant/ZonedDateTime objects (or similar) represent the same instant of time,
regardless of time zone. A thin wrapper over `ZonedDateTime/isEqual`
raw docstring

sliceclj

(slice start-inst stop-inst step-dur)

Inputs: [start-inst :- Temporal stop-inst :- Temporal step-dur :- TemporalAmount] Returns: [Temporal]

Returns a vector of instants in the half-open interval [start stop) (both instants) with increment <step> (a period). Not lazy. Example:

 (range (zoned-date-time 2018 9 1)
        (zoned-date-time 2018 9 5)
        (Duration/ofDays 1)))  => <vector of 4 ZonedDateTime's from 2018-9-1 thru 2018-9-4>
Inputs: [start-inst :- Temporal stop-inst :- Temporal step-dur :- TemporalAmount]
Returns: [Temporal]

Returns a vector of instants in the half-open interval [start stop) (both instants)
with increment <step> (a period). Not lazy.  Example:

     (range (zoned-date-time 2018 9 1)
            (zoned-date-time 2018 9 5)
            (Duration/ofDays 1)))  => <vector of 4 ZonedDateTime's from 2018-9-1 thru 2018-9-4>
raw docstring

str->Instantclj

(str->Instant s)

Inputs: [s :- s/Str] Returns: Instant

Parse a string into a java.time.Instant. Valid formats include:

1999-12-31                          ; LocalDate (assumes utc & start-of-day (00:00:00)
1999-12-31 11:22:33                 ; sql timestamp (assumes utc)
1999-12-31T11:22:33                 ; LocalDateTime (assumes utc)
1999-12-31T11:22:33.123             ; LocalDateTime (assumes utc)
1999-12-31T11:22:33z                ; Instant (ISO 8601)
1999-12-31 11:22:33Z                ; ISO 8601 'nice' format
1999-12-31T11:22:33.123z            ; Instant
1999-12-31T11:22:33+00:00           ; ZonedDateTime
1999-12-31T11:22:33.123+00:00[UTC]  ; ZonedDateTime
Inputs: [s :- s/Str]
Returns: Instant

Parse a string into a java.time.Instant. Valid formats include:

    1999-12-31                          ; LocalDate (assumes utc & start-of-day (00:00:00)
    1999-12-31 11:22:33                 ; sql timestamp (assumes utc)
    1999-12-31T11:22:33                 ; LocalDateTime (assumes utc)
    1999-12-31T11:22:33.123             ; LocalDateTime (assumes utc)
    1999-12-31T11:22:33z                ; Instant (ISO 8601)
    1999-12-31 11:22:33Z                ; ISO 8601 'nice' format
    1999-12-31T11:22:33.123z            ; Instant
    1999-12-31T11:22:33+00:00           ; ZonedDateTime
    1999-12-31T11:22:33.123+00:00[UTC]  ; ZonedDateTime
raw docstring

tagval->LocalDateclj

(tagval->LocalDate ldtv)

Inputs: [ldtv :- {:LocalDate s/Str}] Returns: LocalDate

Parses a tagval into a java.time.LocalDate

Inputs: [ldtv :- {:LocalDate s/Str}]
Returns: LocalDate

Parses a tagval into a java.time.LocalDate
raw docstring

Temporal?clj

(Temporal? it)

Returns true iff arg is an instance of java.time.temporal.Temporal

Returns true iff arg is an instance of java.time.temporal.Temporal 
raw docstring

Timestamp-str?clj

(Timestamp-str? s)

Inputs: [s :- s/Str] Returns: s/Bool

Returns true if string matches a SQL Timestamp pattern like '1999-12-31 11:22:33'

Inputs: [s :- s/Str]
Returns: s/Bool

Returns true if string matches a SQL Timestamp pattern like '1999-12-31 11:22:33' 
raw docstring

truncated-toclj

(truncated-to temporal chrono-unit)

Inputs: [temporal :- Temporal chrono-unit :- ChronoUnit]

Returns a Temporal truncated to corresponding ChronoUnit. Example:

  (truncated-to t ChronoUnit/HOURS)
Inputs: [temporal :- Temporal chrono-unit :- ChronoUnit]

Returns a Temporal truncated to corresponding ChronoUnit.  Example:

      (truncated-to t ChronoUnit/HOURS)
raw docstring

tuid-strclj

(tuid-str)

Inputs: [] Returns: s/Str

Returns a 'Time Unique ID' (TUID), a human-readable UUID-cousin (44-char string) based on the current java.time.Instant. From MSB->LSB, it is composed of a 38-bit epoch second field (valid years: 1970-9999), a 30-bit (9-digit) nanosecond field, and a 64-bit random field.

  128 bits total:  <34-bit-unix-sec> + <30 bit nanos> + <64 bits rand>
  Format:  YYYY-MMDD-HHMMSS-nanosec*9-rndhex*8-rndhex*8  ; string format
  Sample:  2021-0714-191716-123456789-da39a3ee-5e6b4b0d  ; sample value

For 2 TUIDs constructed at random on the same day, there are approx 110 bits of randomness: seconds ~ 16 bits, nanosec ~ 30 bits, rndhex = 64 bits.

For 2 TUIDS constructed at random in the same second, there are still ~94 bits of randomness.

Inputs: []
Returns: s/Str

Returns a 'Time Unique ID' (TUID), a human-readable UUID-cousin (44-char string) based
 on the current java.time.Instant. From MSB->LSB, it is composed of a 38-bit epoch second field
 (valid years: 1970-9999), a 30-bit (9-digit) nanosecond field, and a 64-bit random field.

      128 bits total:  <34-bit-unix-sec> + <30 bit nanos> + <64 bits rand>
      Format:  YYYY-MMDD-HHMMSS-nanosec*9-rndhex*8-rndhex*8  ; string format
      Sample:  2021-0714-191716-123456789-da39a3ee-5e6b4b0d  ; sample value

 For 2 TUIDs constructed at random on the same day, there are approx 110 bits of randomness:
    seconds ~ 16 bits, nanosec ~ 30 bits, rndhex = 64 bits.

 For 2 TUIDS constructed at random in the same second, there are still ~94 bits of randomness.
 
raw docstring

tuid-str?clj

(tuid-str? s)

Inputs: [s :- s/Str] Returns: s/Bool

Returns true if a string is a valid TUID regex pattern

Inputs: [s :- s/Str]
Returns: s/Bool

Returns true if a string is a valid TUID regex pattern
raw docstring

walk-LocalDate->tagvalclj

(walk-LocalDate->tagval data)

with-zoneidcljmacro

(with-zoneid zone-id & forms)

year-quarter?clj

(year-quarter? arg)

Inputs: [arg] Returns: s/Bool

Returns true iff arg is indicates a (financial) quarter in the year.

Inputs: [arg]
Returns: s/Bool

Returns true iff arg is indicates a (financial) quarter in the year.
raw docstring

year-quartersclj


zoned-date-timeclj

(zoned-date-time)
(zoned-date-time year)
(zoned-date-time year month)
(zoned-date-time year month day)
(zoned-date-time year month day hour)
(zoned-date-time year month day hour minute)
(zoned-date-time year month day hour minute second)
(zoned-date-time year month day hour minute second nanos)
(zoned-date-time year month day hour minute second nanos zone-id)

Returns a java.time.ZonedDateTime with the specified parameters and truncated values (day/month=1, hour/minute/sec=0) for all other date/time components. Assumes time zone is UTC unless the maximum-arity constructor is used. Usage:

; Assumes UTC time zone (zoned-date-time) => current time (zoned-date-time year) (zoned-date-time year month) (zoned-date-time year month day) (zoned-date-time year month day hour) (zoned-date-time year month day hour minute) (zoned-date-time year month day hour minute second) (zoned-date-time year month day hour minute second nanos)

; Explicit time zone (zoned-date-time year month day hour minute second nanos zone-id)

; Explicit time zone alternate shortcut arities. (with-zoneid zoneid-us-eastern (zoned-date-time year month day ...)) ; any arity w/o zone-id

Returns a java.time.ZonedDateTime with the specified parameters and truncated values (day/month=1, hour/minute/sec=0)
for all other date/time components. Assumes time zone is UTC unless the maximum-arity constructor is used. Usage:

; Assumes UTC time zone
(zoned-date-time)          => current time
(zoned-date-time year)
(zoned-date-time year month)
(zoned-date-time year month day)
(zoned-date-time year month day hour)
(zoned-date-time year month day hour minute)
(zoned-date-time year month day hour minute second)
(zoned-date-time year month day hour minute second nanos)

; Explicit time zone
(zoned-date-time year month day hour minute second nanos zone-id)

; Explicit time zone alternate shortcut arities.
(with-zoneid zoneid-us-eastern
  (zoned-date-time year month day ...))  ; any arity w/o zone-id

raw docstring

ZonedDateTime-str?clj

(ZonedDateTime-str? s)

Inputs: [s :- s/Str] Returns: s/Bool

Returns true if string matches a Instant pattern like '1999-12-31T11:22:33-08:00Z'

Inputs: [s :- s/Str]
Returns: s/Bool

Returns true if string matches a Instant pattern like '1999-12-31T11:22:33-08:00Z' 
raw docstring

ZonedDateTime?clj

(ZonedDateTime? it)

Returns true iff arg is an instance of java.time.ZonedDateTime

Returns true iff arg is an instance of java.time.ZonedDateTime
raw docstring

zoneid-us-alaskaclj


zoneid-us-aleutianclj


zoneid-us-centralclj


zoneid-us-easternclj


zoneid-us-hawaiiclj


zoneid-us-mountainclj


zoneid-us-pacificclj


zoneid-utcclj

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close