The date time object as a JavaScript date.
The date time in an ISO 8601 format.
The timezone.
The date time value.
Return the full IANA timezone name or an empty string if it can't be found.
An optional callback invoked to see if the timezone is valid.
The IANA timezone name or an empty string if the timezone name isn't valid.
Compares the value's kind.
The kind to compare against.
True if the kind matches.
Returns true if the haystack filter matches the value.
The filter to test.
Optional
cx: Partial<EvalContext>Optional haystack filter evaluation context.
True if the filter matches ok.
A JSON reprentation of the object.
Static
getIANATimeReturn the full IANA timezone name or an empty string if it can't be found.
The timezone name can be a full existing timezone or an alias.
Since a vanilla JavaScript environment doesn't have support for querying the IANA database, a callback function needs to be passed in to query the local database implementation.
Here's an example that uses Luxon...
import { DateTime } from 'luxon'
...
const isValidTimeZone = (timezone: string): boolean =>
!!DateTime.now().setZone(timezone).isValid
const tz = getIANATimeZone('New_York', isValidTimeZone) // Returns 'America/New_York'.
...
Here's an example that uses Moment with timezones...
import * as moment from 'moment-timezone'
...
const isValidTimeZone = (timezone: string): boolean =>
!!moment.tz.zone(timezone)
const tz = getIANATimeZone('New_York', isValidTimeZone) // Returns 'America/New_York'.
A full timezone name or alias.
An optional callback invoked to see if the timezone is valid.
The IANA timezone name or an empty string if the timezone name isn't valid.
Static
getThe timezone database.
Static
makeFactory method for a haystack date time.
The date time as a string, a JS Date or Hayson date object.
A haystack date time.
Static
nowGenerated using TypeDoc
Haystack date time.