TAU

TAU

Source:

Methods

(static) fromIsoToMillis(isonon-null) → (non-null) {number}

Source:
Since:
See:

Converts ISO 8601-compliant string representation to the number of milliseconds since the Unix epoch.

Example
TAU.fromIsoToMillis('1970-01-01T00:00:12.345Z') //=> 12345
Parameters:
Name Type Description
iso string

ISO 8601-compliant representation

Returns:

Number of milliseconds since the Unix epoch

Type
number

(static) fromIsoToUnix(isonon-null) → (non-null) {number}

Source:
Since:
See:

Converts ISO 8601-compliant string representation to the number of seconds since the Unix epoch.

Example
TAU.fromIsoToUnix('1970-01-01T00:00:12.345Z') //=> 12
Parameters:
Name Type Description
iso string

ISO 8601-compliant representation

Returns:

Number of seconds since the Unix epoch

Type
number

(static) fromMillisToIso(millisecondsnon-null) → (non-null) {string}

Source:
Since:
See:

Converts the number of milliseconds since the Unix epoch to ISO 8601-compliant string representation.

Example
TAU.fromMillisToIso(12345) //=> 1970-01-01T00:00:12.345Z
Parameters:
Name Type Description
milliseconds number

Number of milliseconds since the Unix epoch

Returns:

ISO 8601-compliant representation

Type
string

(static) fromMillisToUnix(millisecondsnon-null) → (non-null) {number}

Source:
Since:
See:

Converts the number of milliseconds since the Unix epoch to the number to seconds since the Unix epoch.

Example
TAU.fromMillisToUnix(12000) //=> 12
Parameters:
Name Type Description
milliseconds number

Number of milliseconds since the Unix epoch

Returns:

Number of seconds since the Unix epoch

Type
number

(static) fromNow() → (non-null) {DateTime}

Source:
Since:
See:
  • TAU.fromNowWithOptions, TAU.fromNowUtc

Creates a DateTime from the current moment in time in the default zone.

Example
TAU.fromNow() //=> DateTime
Returns:

The DateTime

Type
DateTime

(static) fromNowToIso() → (non-null) {string}

Source:
Since:
See:
  • TAU.fromNowToMillis, TAU.fromNowToUnix

Returns the current time as ISO 8601-compliant string representation.

Example
TAU.fromNowToIso() //=> 2019-01-02T21:11:51.631Z
Returns:

ISO 8601-compliant representation

Type
string

(static) fromNowToMillis() → (non-null) {number}

Source:
Since:
See:
  • TAU.fromNowToUnix, TAU.fromNowToIso

Returns the current number of milliseconds since the Unix epoch.

Example
TAU.fromNowToMillis() //=> 12345678
Returns:

Number of milliseconds since the Unix epoch

Type
number

(static) fromNowToUnix() → (non-null) {number}

Source:
Since:
See:
  • TAU.fromNowToMillis, TAU.fromNowToIso

Returns the current number of seconds since the Unix epoch.

Example
TAU.fromNowToUnix() //=> 12345
Returns:

Number of seconds since the Unix epoch

Type
number

(static) fromNowUtc() → (non-null) {DateTime}

Source:
Since:
See:
  • TAU.fromNowWithOptions, TAU.fromNow

Creates a UTC DateTime from the current moment in time.

Example
TAU.fromNowUtc() //=> DateTime
Returns:

The DateTime with zone set to UTC

Type
DateTime

(static) fromNowWithOptions(optionsnon-null) → (non-null) {DateTime}

Source:
Since:
See:
  • TAU.fromNow, TAU.fromNowUtc

Creates a DateTime with custom options from the current moment in time.

Example
TAU.fromNowWithOptions({zone: 'utc'}) //=> DateTime
Parameters:
Name Type Description
options Options

Options for DateTime

Returns:

The DateTime

Type
DateTime

(static) fromUnix(secondsnon-null) → (non-null) {DateTime}

Source:
Since:
See:
  • TAU.fromUnixWithOptions, TAU.fromUnixUtc, TAU.toUnix

Creates a DateTime from number of seconds since the Unix epoch. Rounds fractional seconds down.

Example
TAU.toMillis(TAU.fromUnix(12)) //=> 12000
Parameters:
Name Type Description
seconds number

Number of seconds since the Unix epoch

Returns:

The DateTime

Type
DateTime

(static) fromUnixToIso(secondsnon-null) → (non-null) {string}

Source:
Since:
See:

Converts the number of seconds since the Unix epoch to ISO 8601-compliant string representation.

Example
TAU.fromUnixToIso(12) //=> 1970-01-01T00:00:12.000Z
Parameters:
Name Type Description
seconds number

Number of seconds since the Unix epoch

Returns:

ISO 8601-compliant representation

Type
string

(static) fromUnixToMillis(secondsnon-null) → (non-null) {number}

Source:
Since:
See:

Converts the number of seconds since the Unix epoch to the number to millisecond since the Unix epoch.

Example
TAU.fromUnixToMillis(12) //=> 12000
Parameters:
Name Type Description
seconds number

Number of seconds since the Unix epoch

Returns:

Number of milliseconds since the Unix epoch

Type
number

(static) fromUnixUtc(secondsnon-null) → (non-null) {DateTime}

Source:
Since:
See:
  • TAU.fromUnixWithOptions, TAU.fromUnix, TAU.toUnix

Creates a UTC DateTime from the number of seconds since the Unix epoch. Rounds fractional seconds down.

Example
TAU.toMillis(TAU.fromUnixUtc(12)) //=> 12000
Parameters:
Name Type Description
seconds number

Number of seconds since the Unix epoch

Returns:

The DateTime with zone set to UTC

Type
DateTime

(static) fromUnixWithOptions(optionsnon-null, secondsnon-null) → (non-null) {DateTime}

Source:
Since:
See:
  • TAU.fromUnix, TAU.fromUnixUtc, TAU.toUnix

Creates a DateTime with custom options from the number of seconds since the Unix epoch. Rounds fractional seconds down.

Example
TAU.toMillis(TAU.fromUnixWithOptions({zone: 'utc'}, 12)) //=> 12000
Parameters:
Name Type Description
options Options

Options for DateTime

seconds number

Number of seconds since the Unix epoch

Returns:

The DateTime

Type
DateTime

(static) toUnix(Thenon-null) → (non-null) {number}

Source:
Since:
See:
  • TAU.fromUnixWithOptions, TAU.fromUnix, TAU.fromUnixUtc

Converts a DateTime to the number of seconds since the Unix epoch. Always returns an integer, rounded down.

Example
TAU.toUnix(TAU.fromMillis(12000)) //=> 12
Parameters:
Name Type Description
The DateTime

DateTime

Returns:

seconds Number of seconds since the Unix epoch

Type
number

(static) withOptions(fnon-null, fnon-null) → (non-null) {function}

Source:
Since:

Wrap a function with options. The function must take a DateTime options object as its first argument.

Example
const withNewYork = TAU.withOptions({zone: 'America/New_York'})
const fromFormatNewYork = TAU.withNewYork(fromFormatWithOptions)
Parameters:
Name Type Description
f options

DateTime options

f function

Function to wrap with options

Returns:

The wrapped function

Type
function

(static) withUtc(fnon-null) → (non-null) {function}

Source:
Since:

Wrap a function with zone UTC. The function must take a DateTime options object as its first argument.

Example
const fromFormatUtc = TAU.withUtc(fromFormatWithOptions)
Parameters:
Name Type Description
f function

Function to wrap with UTC zone

Returns:

The wrapped function

Type
function

(static) withZone(zonenon-null, fnon-null) → (non-null) {function}

Source:
Since:

Wrap a function with a zone. The function must take a DateTime options object as its first argument.

Example
const fromFormatNewYork = TAU.withZone('America/New_York')(fromFormatWithOptions)
Parameters:
Name Type Description
zone string

The zone string

f function

Function to wrap with zone

Returns:

The wrapped function

Type
function