geoview-core
    Preparing search index...

    Class DateMgtAbstract

    Class used to handle date as ISO 8601

    DateMgt

    Index

    Constructors

    Properties

    DEFAULT_DATE_FORMAT: TypeDisplayDateFormat = DateMgt.LONG_DISPLAY_DATE_FORMAT

    The Default date format for English and French to be used by the application

    DEFAULT_DATE_YEAR_ONLY_FORMAT: TypeDisplayDateFormat = DateMgt.ISO_DISPLAY_YEAR_ONLY_FORMAT

    The Default time format for English and French to be used by the application

    DEFAULT_DATETIME_FORMAT: TypeDisplayDateFormat = DateMgt.LONG_DISPLAY_DATETIME_FORMAT

    The Default date and time format for English and French to be used by the application

    DEFAULT_TEMPORAL_MODE: TemporalMode = 'calendar'

    The default temporal mode to be used by the application

    DEFAULT_TIME_FORMAT: TypeDisplayDateFormat = DateMgt.ISO_DISPLAY_TIME_FORMAT_MINUTES

    The Default time format for English and French to be used by the application

    ISO_DATE_FORMAT: "YYYY-MM-DD" = 'YYYY-MM-DD'

    The international ISO date format.

    ISO_DATETIME_FORMAT_FULL: "YYYY-MM-DDTHH:mm:ss.SSS" = 'YYYY-MM-DDTHH:mm:ss.SSS'

    The international ISO datetime format.

    ISO_DATETIME_FORMAT_MINUTES: "YYYY-MM-DDTHH:mm" = 'YYYY-MM-DDTHH:mm'

    The international ISO format without the seconds.

    ISO_DATETIME_FORMAT_SECONDS: "YYYY-MM-DDTHH:mm:ss" = 'YYYY-MM-DDTHH:mm:ss'

    The international ISO format without the milliseconds.

    ISO_DISPLAY_DATE_FORMAT: TypeDisplayDateFormat = ...

    The display format for international ISO date only for English and French

    ISO_DISPLAY_DATETIME_FORMAT_MINUTES: TypeDisplayDateFormat = ...

    A Default time only format for English and French

    ISO_DISPLAY_TIME_FORMAT_MINUTES: TypeDisplayDateFormat = ...

    A Default time only format for English and French

    ISO_DISPLAY_YEAR_ONLY_FORMAT: TypeDisplayDateFormat = ...

    A Default time only format for English and French

    ISO_TIME_FORMAT: "HH:mm:ss" = 'HH:mm:ss'

    The international ISO time format with seconds.

    ISO_TIME_FORMAT_MINUTES: "HH:mm" = 'HH:mm'

    The international ISO time format.

    LONG_DISPLAY_DATE_FORMAT: { en: string; fr: string } = ...

    The Long date format.

    LONG_DISPLAY_DATETIME_FORMAT: { en: string; fr: string } = ...

    The Long datetime format.

    MILLISECONDS_IN_1_DAY: number = ...
    MILLISECONDS_IN_1_YEAR: number = ...
    REGEX_ISO_DATE: RegExp = ...

    Regular expression for matching ISO date strings

    REGEX_ISO_DATE_WITH_PREFIX: RegExp = ...
    TIME_IANA_LOCAL: string = ...

    Static constant indicating the local IANA time zone.

    TIME_UTC: "UTC" = 'UTC'

    Static constant to indicate when we interpret a date as UTC. For general purposes of UTC.

    Methods

    • Convert a date to milliseconds.

      Parameters

      • date: DateLike

        The date to use

      • OptionalinputFormat: string | string[]

        One or more format strings to prioritize when parsing string inputs.

      • OptionalinputTimezone: string

        The timezone to assume for string inputs that do not explicitly include a timezone.

      Returns number

      Date as milliseconds

      If the time zone is not a valid or supported IANA identifier.

    • Creates a native Date object from a DateLike input. This is a convenience wrapper around createDayjs that converts the validated Dayjs instance into a native JavaScript Date.

      Parameters

      • date: DateLike

        The input date to convert. Can be:

        • A Date object
        • A timestamp number
        • A string (ISO, custom format, or calendar/instant date)
      • OptionalinputFormat: string | string[]

        Optional format(s) for parsing string inputs. Passed directly to createDayjs.

      • OptionalinputTimezone: string

        Optional IANA timezone to apply if the input string has no explicit timezone and is parsed as an instant.

      • OptionaltemporalMode: TemporalMode

        Determines how string inputs are interpreted:

        • "calendar": parsed as a calendar date
        • "instant": parsed as an exact point in time Defaults to DEFAULT_TEMPORAL_MODE.

      Returns Date

      A native JavaScript Date object representing the parsed date.

      Throws an error if the input cannot be parsed into a valid date.

      • Parsing, validation, and temporal logic are delegated to createDayjs.
      • The returned Date represents the same instant in time as the underlying Dayjs object.
    • Creates a validated Dayjs instance from a DateLike input. This is a thin wrapper around parseDateToDayjs that ensures the resulting Dayjs object is valid, throwing an error if parsing fails.

      Parameters

      • date: DateLike

        The input date to parse. Can be:

        • A Date object
        • A timestamp number
        • A string (ISO, custom format, or calendar/instant date)
      • OptionalinputFormat: string | string[]

        Optional format(s) for parsing string inputs. Passed directly to parseDateToDayjs.

      • OptionalinputTimezone: string

        Optional IANA timezone to apply if the input string has no explicit timezone and is parsed as an instant.

      • OptionaltemporalMode: TemporalMode

        Determines how string inputs are interpreted:

        • "calendar": parsed as a calendar date
        • "instant": parsed as an exact point in time Defaults to DEFAULT_TEMPORAL_MODE.

      Returns Dayjs

      A valid Dayjs object representing the parsed date.

      When input has invalid date.

      • This method guarantees that the returned Dayjs instance is valid.
      • All parsing rules, timezone handling, and temporal logic are delegated to parseDateToDayjs.
    • Create the Geoview time dimension from ESRI dimension

      Parameters

      • timeDimensionESRI: TimeDimensionESRI

        Esri time dimension object

      • displayDateMode: DisplayDateMode | undefined
      • singleHandle: boolean = false

        True if it is ESRI Image

      Returns TimeDimension

      The Geoview time dimension

      When range couldn't be computed, or when duration is invalid, or non-positive or when an infinite loop is detected.

      When input has invalid dates.

    • Create the Geoview time dimension from OGC dimension

      Parameters

      • ogcTimeDimension: string | TypeMetadataWMSCapabilityLayerDimension

        The OGC time dimension object or string

      • displayDateMode: DisplayDateMode | undefined

      Returns TimeDimension

      • The Geoview time dimension

      When range couldn't be computed, or when duration is invalid, or non-positive or when an infinite loop is detected.

      When input has invalid dates.

    • Create a range of date object from OGC time dimension following ISO 8601

      Parameters

      • ogcTimeDimensionValues: string

        OGC time dimension values following

      Returns RangeItems

      array of date from the dimension

      When range couldn't be computed, or when duration is invalid, or non-positive or when an infinite loop is detected.

      When input has invalid dates.

    • Formats a DateLike value into a string using the specified format, locale, timezone, and temporal interpretation. This method first normalizes the input using parseDateToDayjs, then applies output-specific transformations such as timezone conversion, locale, and formatting.

      Parameters

      • date: DateLike

        The input date to format. Can be:

        • A Date object
        • A timestamp number
        • A string (ISO, custom format, or calendar date)
      • Optionalformat: string = ...

        The Dayjs format string used to produce the output.

      • Optionallocale: TypeDisplayLanguage = 'en'

        Locale used for formatting (e.g. month and weekday names).

      • OptionaloutputTimezone: string = ...

        IANA timezone applied to the output when formatting instant dates.

      • OptionaltemporalMode: TemporalMode = ...

        Determines how the input is interpreted:

        • "calendar": treated as a whole calendar day
        • "instant": treated as an exact point in time
      • OptionalinputFormat: string | string[]

        Optional format(s) for parsing string inputs. If provided, these are passed through to parseDateToDayjs.

      • OptionalinputTimezone: string

        Optional IANA timezone to apply if the input string has no explicit timezone and is parsed as an instant.

      • OptionalwithZ: boolean = false

        Whether to append a literal 'Z' to the formatted output string.

      Returns string

      The formatted date string.

      • The input is always parsed via parseDateToDayjs, ensuring consistent handling of Date, epoch, and string values.
      • Calendar dates are normalized to local midnight and are not shifted to outputTimezone.
      • Instant dates are converted to outputTimezone before formatting.
      • The locale is applied after parsing and timezone adjustments.
    • Formats a date into a short ISO-like string (YYYY-MM-DDTHH:mm:ss). This is a convenience wrapper around formatDate that produces a compact, timezone-aware ISO-style representation, optionally appending a Z suffix when formatted in UTC.

      Parameters

      • date: DateLike

        The input date to format. Can be:

        • A Date object
        • A timestamp number
        • A string (ISO, custom format, or calendar/instant date)
      • OptionaloutputTimezone: string = ...

        IANA timezone applied to the output when formatting instant dates.

      • OptionaltemporalMode: TemporalMode

        Determines how the input is interpreted:

        • "calendar": treated as a calendar date
        • "instant": treated as an exact point in time
      • OptionalinputFormat: string | string[]

        Optional format(s) for parsing string inputs. Passed through to formatDate.

      • OptionalinputTimezone: string = ...

        IANA timezone to apply if the input string has no explicit timezone and is parsed as an instant.

      Returns string

      A short ISO-like formatted date string.

      • Uses the format YYYY-MM-DDTHH:mm:ss.
      • Delegates all parsing and formatting logic to formatDate.
      • Appends a literal 'Z' to the output only when outputTimezone is UTC.
      • Calendar dates are not shifted by outputTimezone.
    • Formats a single date or a date range according to the specified display format, language, timezone, and temporal mode. If a second date is provided, the function returns a string representing the range in the format "date1 / date2".

      Parameters

      • date1: DateLike

        The first date (or the only date) to format.

      • dateFormat: TypeDisplayDateFormat

        Object containing the display format for each language.

      • locale: TypeDisplayLanguage

        Language code to select the correct format from dateFormat.

      • OptionaloutputTimezone: string

        The IANA timezone to use for output formatting.

      • OptionalinputTemporalMode: TemporalMode

        Whether to interpret the input as 'calendar' or 'instant'.

      • Optionaldate2: DateLike

        Optional second date for formatting a date range.

      Returns string

      A formatted date string or a formatted date range string.

    • Formats a single date or a date range according to the specified display format, language, timezone, and temporal mode. If a second date is provided, the function returns a string representing the range in the format "date1 / date2".

      Parameters

      • date1: DateLike

        The first date (or the only date) to format.

      • referenceFormat: TypeDisplayDateFormat
      • OptionalinputTemporalMode: TemporalMode

        Whether to interpret the input as 'calendar' or 'instant'.

      • Optionaldate2: DateLike

        Optional second date for formatting a date range.

      Returns string

      A formatted date string or a formatted date range string.

    • Attempts to infer display date configuration from a service-provided date format string. The function inspects the format string to determine whether it contains time-related components (e.g., hours, minutes, seconds, timezone tokens). If time components are detected, it assumes:

      • The date represents an instant (not a calendar-only date).
      • The display timezone should default to local. If no time components are detected or the format is undefined, no assumptions are made and undefined is returned.

      Parameters

      • serviceDateFormat: string | undefined

        The date format string provided by the service (e.g., "YYYY-MM-DDTHH:mm:ss").

      Returns GuessedTimeInformation | undefined

      A partial GuessedTimeInformation object containing inferred display settings if time components are detected; otherwise undefined.

      • This function performs heuristic inference and may not be accurate for all custom or non-standard format strings.
      • Errors during evaluation are logged and do not propagate.
    • Attempts to infer display date configuration from a service time dimension. This function analyzes an array of date values and applies heuristics based on the overall time span and time-of-day consistency to determine:

      • Whether the dates should be treated as instant or calendar values.
      • Which display format is most appropriate.
      • Whether a timezone assumption should be applied. Heuristic rules:
      1. If the total time span between the first and last date is ≤ 1 day:
        • Assume the values represent instants within a single day.
        • Use full datetime formatting.
        • Default display timezone to local.
        • Set temporal mode to instant.
      2. If the total time span is ≥ 10 years:
        • Assume a long-term dataset where year-level precision is sufficient.
        • Use year-only short formatting.
      3. If all dates share the exact same UTC time-of-day (same hours, minutes, seconds):
        • Assume the time component is not meaningful.
        • Use date-only formatting. If none of the heuristics apply, the function returns undefined.

      Parameters

      • dates: DateLike[]

        Array of service-provided date values to analyze.

      • displayDateMode: DisplayDateMode | undefined

      Returns GuessedTimeInformation | undefined

      A partially populated GuessedTimeInformation object if a confident inference can be made; otherwise undefined.

      • All comparisons are performed in UTC.
      • This function relies on heuristics and may not be correct for all datasets.
      • Errors during parsing are logged and do not propagate.
    • Guesses the estimated steps that should be used by the slider, depending on the value range

      Parameters

      • minValue: number

        The minimum value

      • maxValue: number

        The maximum value

      Returns number | undefined

      The estimated stepping value based on the min and max values

    • Determines whether a date/time format string contains any supported time-related tokens. The method performs a simple substring check against a predefined list of time tokens (e.g. hours, minutes, seconds, meridiem, Unix time). If the format is undefined, the method safely returns false.

      Parameters

      • format: string | undefined

        The date/time format string to evaluate. May be undefined.

      Returns boolean

      true if the format contains at least one recognized time token; otherwise false.

    • Checks whether a given IANA time zone is supported by the runtime. Validation is performed using Day.js with the timezone plugin, which relies on the underlying Intl time zone database.

      Parameters

      • timezone: string

        IANA time zone identifier to check

      Returns boolean

      true if the time zone is valid and supported, otherwise false

    • Parses a date string as a calendar date, ignoring any timezone or offset semantics and preserving the civil date and time fields as-is. This function interprets the input purely in terms of its calendar components (year, month, day, and optional time), then normalizes those components by re-anchoring them in UTC. No timezone conversion is applied. This guarantees that calendar-based dates do not shift days due to timezone offsets, DST, or environment locale.

      Parameters

      • date: string

        Date string to parse

      • OptionalinputFormat: string | string[]

        Optional format or list of formats used to parse the input date string

      • Optionalstrict: boolean = false

        Whether to enforce strict parsing when using custom formats

      Returns Dayjs

      Dayjs instance normalized to UTC using calendar semantics

    • Parses a DateLike input into a Dayjs object, automatically handling different types of input and temporal modes. Supports:

      1. Epoch numbers and Date objects (treated as exact UTC instants)
      2. String representations as either "instant" or "calendar" dates
      3. Optional custom input formats, strict parsing, and timezones

      Parameters

      • date: DateLike

        The input date. Can be:

        • A Date object
        • A timestamp number
        • A string (ISO, custom format, or calendar date)
      • OptionalinputFormat: string | string[]

        Optional format(s) for parsing string inputs. If provided, Dayjs will use these formats instead of auto-detection.

      • OptionalinputTimezone: string

        Optional IANA timezone to apply if the input string does not have an explicit timezone. Defaults to TIME_UTC in parseInstantDate.

      • OptionaltemporalMode: TemporalMode = ...

        Determines how string inputs are interpreted:

        • "instant": exact point in time
        • "calendar": normalized to midnight local time
      • Optionalstrict: boolean = false

        If true, enforces strict parsing according to the provided inputFormat.

      Returns Dayjs

      A Dayjs object representing the parsed date.

      • If date is a number or Date, it is parsed as a UTC instant.
      • If date is a string containing a timezone, it is treated as an "instant" date.
      • If inputTemporalMode is "calendar", the string is parsed with parseCalendarDate and normalized to local midnight.
      • Otherwise, the string is parsed as an instant using parseInstantDate.
      • This method automatically determines the correct parsing helper based on the input.
    • Parses a string as an "instant" point in time into a Dayjs object. Handles:

      1. Optional custom input formats
      2. Strings with or without explicit timezones
      3. Applying a default timezone if missing

      Parameters

      • date: string

        The input date string to parse.

      • OptionalinputFormat: string | string[]

        Optional format(s) for parsing. If provided, Dayjs will use these formats instead of auto-detection.

      • OptionalinputTimezone: string = ...

        IANA timezone string to apply if the input string has no explicit timezone.

      • Optionalstrict: boolean = false

        If true, enforces strict parsing according to the provided inputFormat.

      Returns Dayjs

      A Dayjs object representing the parsed instant.

      If the time zone is not a valid or supported IANA identifier.

      • If the input string contains a timezone (hasTZ is true), it is treated as an exact instant.
      • If the input string lacks a timezone, inputTimezone is applied.
    • Checks if whatever is sent looks like it could be a date.

      Parameters

      • date: string

        The string to parse to check if it's a date.

      • OptionalinputTimezone: string

        The timezone to assume for string inputs that do not explicitly include a timezone.

      Returns Date | undefined

      A native Date object representing the parsed instant in UTC or undefined if parsing fails.

    • Validates that a given IANA time zone is supported by the runtime.

      Parameters

      • timezone: string

        IANA time zone identifier (e.g. 'America/Toronto', 'Europe/Paris', 'UTC')

      Returns void

      If the time zone is not a valid or supported IANA identifier.