Methods
(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}
Creates a DateTime from the current moment in time in the default zone.
Example
TAU.fromNow() //=> DateTime
Returns:
The DateTime
- Type
- DateTime
(static) fromNowUtc() → (non-null) {DateTime}
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}
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}
Creates a DateTime from number of seconds since the Unix epoch.
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) 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}
Creates a UTC DateTime from the number of seconds since the Unix epoch.
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}
Creates a DateTime with custom options from the number of seconds since the Unix epoch.
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}
Converts a DateTime to the number of seconds since the Unix epoch.
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