Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "geocortex/infrastructure/TimeZoneUtils"

Index

Variables

Const UTC_ZONE_ID

UTC_ZONE_ID: string

The code here has been moved to geocortex/essentials/utilities so that it can be consumed by code in MapService.ts A copy has been left here for backwards compatibility

Functions

correctDatesForDisplayInDisplayTimeZone

  • correctDatesForDisplayInDisplayTimeZone(date: Date, databaseTimeZoneId: string, displayTimeZoneId: string): Date
  • This method offsets displayed dates to display to the user in a time zone defined by an administrator. JavaScript's native Date objects automatically display themselves in the local time of the client machine. For example, if a date reads 3PM in New York, in general that same date will read 12PM in Los Angeles. This is not appropriate for all applications; sometimes we would like to make sure a date has the same display value to any user in any location. The current method accomplishes that.

    Parameters

    • date: Date

      The date to modify for display.

    • databaseTimeZoneId: string

      The time zone of the date as stored in the database.

    • displayTimeZoneId: string

      The time zone in which the date should be displayed.

    Returns Date

correctDatesForDisplayInLocalTime

  • correctDatesForDisplayInLocalTime(date: Date, timeZoneId: string): Date
  • Many users store dates in their local time zones, and they may not advertise this fact to ArcGIS Server. This may cause a mismatch when ArcGIS Server serializes the date field as a UNIX timestamp, whose time zone is always UTC (also known as GMT). Thus the browser will offset the dates it displays in local time, assuming that its Date objects are generated from UNIX timestamps; in this function, dates' presentable values are offset to their true UTC values, depending on the time zone ID for the layer (or map service, or site) containing this date. If there is no time zone ID, this function should not be called; if the time zone ID is a UTC equivalent (e.g., Etc/GMT, Etc/UCT, Etc/UCT), then no offset should be applied.

    Parameters

    • date: Date

      The date to potentially offset.

    • timeZoneId: string

      The IANA ID of the time zone in which the data are recorded in the database

    Returns Date

correctDatesToQueryInDatabaseTime

  • correctDatesToQueryInDatabaseTime(date: Date, databaseTimeZoneId: string, displayTimeZoneId?: string): Date
  • The QueryBuilder takes date objects implicitly in local time (with respect to the browser) and parses them as strings, which we then submit as a query. This is not always appropriate if, for example, the database is properly-configured in UTC, or if it happens to be in another time zone. Hence this method corrects a date from the browser's time to the zone corresponding to the given database and display time zone IDs.

    Parameters

    • date: Date

      The date to offset

    • databaseTimeZoneId: string

      The IANA ID of the time zone in which the data are recorded in the database

    • Optional displayTimeZoneId: string

      The IANA ID of the time zone in which the data are displayed.

    Returns Date

correctDatesToSubmitInDatabaseTime

  • correctDatesToSubmitInDatabaseTime(date: Date, databaseTimeZoneId: string, displayTimeZoneId?: string): Date
  • Many users store dates in their local time zones, and they may not advertise this fact to ArcGIS Server. This may cause a mismatch when ArcGIS Server serializes the date field as a UNIX timestamp, whose time zone is always UTC (also known as GMT). Thus the browser will submit dates to the server in UTC, regardless of which time zone the data are stored in; in this function, dates' submitted values are offset to their true UTC values, depending on the time zone ID for the layer (or map service, or site) containing this date. If there is no time zone ID, this function should not be called; if the time zone ID is a UTC equivalent (e.g., Etc/GMT, Etc/UCT, Etc/UCT), then no offset should be applied.

    Parameters

    • date: Date

      The date to offset

    • databaseTimeZoneId: string

      The IANA ID of the time zone in which the data are recorded in the database

    • Optional displayTimeZoneId: string

      The IANA ID of the time zone in which the data are displayed to the user.

    Returns Date

getDisplayTimeZoneFromMapService

  • getDisplayTimeZoneFromMapService(holder: MapService): string
  • Retrieves the display time zone from a map service's site.

    Parameters

    • holder: MapService

      The map service whose display time zone we are interrogating.

    Returns string

getTimeZoneFromLayer

  • getTimeZoneFromLayer(holder: Layer): string
  • Retrieves the time zone from a layer (or the layer's map service, or the site).

    Parameters

    • holder: Layer

      The layer whose time zone we are interrogating.

    Returns string

getTimeZoneFromMapService

  • getTimeZoneFromMapService(holder: MapService): string
  • Retrieves the time zone from a map service (or the site).

    Parameters

    • holder: MapService

      The map service whose time zone we are interrogating.

    Returns string