tech.v3.datatype.datetime

Thorough bindings to java.time.datetime. Includes packed datatypes and lifting various datetime datatypes into the datatype system.

A general outline is:

  • There are a set of type-hinted constants you can use in your code however you like.

    • milliseconds-in-day, nanoseconds-in-second, etc.
  • There are type-hinted constructors for the types and ways to take a type and convert it to another type.

    • local-date, instant, zoned-date-time, etc.
    • local-date->instant, instant->zoned-date-time, etc.
  • There are a few generalized functions to create new datetime types or to convert a datetime type into milliseconds-since-epoch and back and to add/subtract integer amounts of different chronographic units:

    • datetime->milliseconds, milliseconds->datetime
    • plus-temporal-amount, minus-temporal-amount, long-temporal-amount
    • between

between

(between lhs rhs units)

Find the time unit between two datetime objects. Must have the same datatype. Units may be a chronounit or one of #{:milliseconds :seconds :minutes :hours :days :weeks :months :years} Returns longs or long readers. Note that support for the various units across java.time the datatypes is partial.

datetime->epoch

(datetime->epoch timezone epoch-datatype data)(datetime->epoch epoch-datatype data)(datetime->epoch data)

Convert datetime data to one of the epoch timestamps. If timezone is passed in it is used else UTC is used.

  • timezone a java.time.ZoneId or nil.
  • epoch-datatype - one of #{:epoch-microseconds :epoch-milliseconds :epoch-seconds :epoch-days}
  • data - datetime scalar or vector data.

datetime->milliseconds

(datetime->milliseconds timezone data)(datetime->milliseconds data)

Vectorized conversion of a datetime datatype to milliseconds with a given timezone (or utc timezone) and an implied 0 time offset.

datetime-datatype?

(datetime-datatype? datatype)

days-since-epoch->local-date

(days-since-epoch->local-date days zone-id)(days-since-epoch->local-date days)

duration

(duration)(duration arg)

duration->milliseconds

(duration->milliseconds duration)

duration->nanoseconds

(duration->nanoseconds duration)

duration-datatype?

(duration-datatype? dtype)

epoch->datetime

(epoch->datetime timezone epoch-datatype datetime-datatype data)(epoch->datetime timezone datetime-datatype data)(epoch->datetime datetime-datatype data)

Convert data in long or integer epoch data to a datetime datatype.

  • timezone - java.time.ZoneId or nil.
  • epoch-datatype - one of #{:epoch-microseconds :epoch-milliseconds :epoch-seconds :epoch-days}. In the case where it is not provided the elemwise-datatype of data must one of that set.
  • datetime-datatype - The target datatype.
  • data - data in integer or long format.

epoch-days->epoch-months

(epoch-days->epoch-months ed)

epoch-months->epoch-days

(epoch-months->epoch-days em)

epoch-months->local-date

(epoch-months->local-date em)

instant

(instant)(instant arg)

instant->local-date-time

(instant->local-date-time inst zone-id)(instant->local-date-time inst)

instant->microseconds-since-epoch

(instant->microseconds-since-epoch instant)

instant->milliseconds-since-epoch

(instant->milliseconds-since-epoch instant)

instant->seconds-since-epoch

(instant->seconds-since-epoch instant)

instant->zoned-date-time

(instant->zoned-date-time inst zid)(instant->zoned-date-time inst)

local-date

(local-date)

local-date->days-since-epoch

(local-date->days-since-epoch ld local-time zoneid)(local-date->days-since-epoch ld zoneid)(local-date->days-since-epoch ld)

local-date->epoch-months

(local-date->epoch-months ld)

local-date->instant

(local-date->instant ld lt zoneid-or-offset)(local-date->instant ld zone-id)(local-date->instant ld)

local-date->local-date-time

(local-date->local-date-time ld lt)(local-date->local-date-time ld)

local-date->milliseconds-since-epoch

(local-date->milliseconds-since-epoch ld lt zoneid)(local-date->milliseconds-since-epoch ld zoneid)(local-date->milliseconds-since-epoch ld)

local-date->zoned-date-time

(local-date->zoned-date-time ld lt zoneid)(local-date->zoned-date-time ld zone-id)(local-date->zoned-date-time ld)

local-date-time

(local-date-time)(local-date-time arg)

local-date-time->instant

(local-date-time->instant ldt zone-or-offset)(local-date-time->instant ldt)

local-date-time->local-date

(local-date-time->local-date ldt)

local-date-time->local-time

(local-date-time->local-time ldt)

local-date-time->milliseconds-since-epoch

(local-date-time->milliseconds-since-epoch ldt timezone)(local-date-time->milliseconds-since-epoch ldt)

local-date-time->zoned-date-time

(local-date-time->zoned-date-time ldt zone-id)(local-date-time->zoned-date-time ldt)

local-time

(local-time)(local-time arg)

local-time->instant

(local-time->instant lt)(local-time->instant lt ld)

local-time->local-date-time

(local-time->local-date-time ldt day)(local-time->local-date-time ldt)

local-time->milliseconds

(local-time->milliseconds lt)

local-time->seconds

(local-time->seconds lt)

long-temporal-field

(long-temporal-field tf data)

Given a temporal field (or a keyword representing desired field) return an :int64 thing that represents that value of this temporal. Temporal fields are: #{:iso-day-of-week :iso-week-of-year :day-of-week :months :days :seconds :epoch-days :day-of-year :hours :years :milliseconds :minutes :week-of-year}.

Not all temporal objects support all temporal fields. Also, if you are looking to convert a thing to seconds-since-epochs please see datetime->milliseconds.

microseconds-since-epoch->instant

(microseconds-since-epoch->instant microseconds-since-epoch)

millisecond-descriptive-statistics

(millisecond-descriptive-statistics stats-seq options data)(millisecond-descriptive-statistics data)

Get the descriptive stats. Stats are calulated in milliseconds and then min, mean, max are returned as objects of the unpacked datetime datatype. Any other stats values are returned in milliseconds unless the input is a duration or packed duration type in which case standard deviation is also a duration datatype.

milliseconds->datetime

(milliseconds->datetime datatype timezone milli-data)(milliseconds->datetime datatype milli-data)

Vectorized Conversion of milliseconds to a given datetime datatype using defaults. Specialized conversions for particular datatypes also available as overrides or tech.v2.datatype.datetime/milliseconds-since-epoch->X where X can be: local-date local-date-time zoned-date-time.

milliseconds->duration

(milliseconds->duration millis)

milliseconds->local-time

(milliseconds->local-time milliseconds)

milliseconds-in-day

milliseconds-in-hour

milliseconds-in-minute

milliseconds-in-second

milliseconds-in-week

milliseconds-since-epoch->instant

(milliseconds-since-epoch->instant arg)

milliseconds-since-epoch->local-date

(milliseconds-since-epoch->local-date millis)(milliseconds-since-epoch->local-date millis zone-id)

milliseconds-since-epoch->local-date-time

(milliseconds-since-epoch->local-date-time millis)(milliseconds-since-epoch->local-date-time millis zone-id)

milliseconds-since-epoch->local-time

(milliseconds-since-epoch->local-time millis)

milliseconds-since-epoch->zoned-date-time

(milliseconds-since-epoch->zoned-date-time zid timezone)(milliseconds-since-epoch->zoned-date-time zid)

minus-temporal-amount

(minus-temporal-amount datetime-data long-data tf)(minus-temporal-amount datetime-data long-data)

Subtract a given temporal amount (in integers) to a temporal dataset. Valid temporal amounts are: #{:months :days :seconds :hours :years :milliseconds :minutes :weeks}

nanoseconds->duration

(nanoseconds->duration nanos)

nanoseconds-in-day

nanoseconds-in-hour

nanoseconds-in-millisecond

nanoseconds-in-minute

nanoseconds-in-second

nanoseconds-in-week

plus-temporal-amount

(plus-temporal-amount datetime-data long-data tf)(plus-temporal-amount datetime-data long-data)

Add a given temporal amount (in integers) to a temporal dataset. Valid temporal amounts are: #{:months :days :seconds :hours :years :milliseconds :minutes :weeks}

seconds->local-time

(seconds->local-time seconds)

seconds-in-day

seconds-in-hour

seconds-in-minute

seconds-since-epoch->instant

(seconds-since-epoch->instant seconds)

system-zone-id

(system-zone-id)

system-zone-offset

(system-zone-offset)

utc-zone-id

(utc-zone-id)

utc-zone-offset

(utc-zone-offset)

variable-rolling-window-ranges

(variable-rolling-window-ranges src-data window-length units options)(variable-rolling-window-ranges src-data window-length units)

Given a reader of monotonically increasing source datetime data, return an iterable of ranges that describe the windows in index space. There will be one window per source input and windows are applied in int64 microsecond space. Be aware that windows near the end cannot possibly satisfy the windowing requirement.

See options for tech.v3.datatype.rolling/variable-rolling-window-ranges for further options, of which stepsize may be of interest.

zoned-date-time

(zoned-date-time)(zoned-date-time arg)

zoned-date-time->instant

(zoned-date-time->instant zid)(zoned-date-time->instant zdt tz)

zoned-date-time->milliseconds-since-epoch

(zoned-date-time->milliseconds-since-epoch zid)(zoned-date-time->milliseconds-since-epoch zdt zid)