TZUtils
@codification/cutwater-core > TZUtils
Class
A simple utility for handling timezones.
beta:
Hierarchy
TZUtils
Properties
Accessors
Methods
Properties
<Static> DEFAULT_OFFSET
● DEFAULT_OFFSET: number = 0
Defined in TZUtils.ts:22
The default timezone offset if UTC_OFFSET is not set in Config.
readonly:
<Static> ENV_OFFSET
● ENV_OFFSET: string = "UTC_OFFSET"
Defined in TZUtils.ts:15
Name of value read from Config to determine initial timezone if present.
readonly:
<Static> FORMAT_TIMESTAMP
● FORMAT_TIMESTAMP: string = "YYYY-MM-DD HH:mm:ss,SSS"
Defined in TZUtils.ts:29
The default format used when calling TZUtils.timestamp.
readonly:
Accessors
<Static> now
get now(): Date
Defined in TZUtils.ts:68
A Date object representing the date/time at the current TZUtils.timezoneOffset.
readonly:
Returns: Date
<Static> timezoneOffset
get timezoneOffset(): number
set timezoneOffset(minutes: number): void
Defined in TZUtils.ts:45
The current offset in minutes from UTC. May be positive or negative.
Returns: number
Defined in TZUtils.ts:41
The current offset in minutes from UTC. May be positive or negative.
Parameters:
| Name | Type |
|---|---|
| minutes | number |
Returns: void
Methods
<Static> resetTimezoneOffset
▸ resetTimezoneOffset(): void
Defined in TZUtils.ts:34
Resets the TZUtils.timezoneOffset to TZUtils.DEFAULT_OFFSET.
Returns: void
<Static> timestamp
▸ timestamp(format?: string): string
Defined in TZUtils.ts:59
Returns the current timestamp as a string. The actual value depends on both the TZUtils.timezoneOffset and the optionally provided format.
- Please see the date-fns project for details about the valid values for the format string.
Parameters:
| Name | Type | Default value | Description |
|---|---|---|---|
Default value format | string | this.FORMAT_TIMESTAMP | the optional date-fns style format for the output |
Returns: string
a string timestamp reflecting the current timezone offset