Documentation

{{docApp.title}}

{{docApp.description}}

How can we help?

{{docApp.searchError}}

{{docApp.searchResultFilteredItems.length}} results for: {{docApp.currentResultsSearchText}} in {{docApp.searchFilterBySpecificBookTitle}}

You have an odd number of " characters in your search terms - each one needs closing with a matching " character!

{{docApp.libraryHomeViewProduct.title || docApp.libraryHomeViewProduct.id}}

{{docApp.libraryHomeViewProduct.description}}

  1. {{book.title}}

{{group.title || group.id}}

{{group.description}}

  1. {{book.title}}

{{group.title}}

Working with Date/Time Values

When dealing with date and time values in computer systems, ambiguity in formats and time representation can pose significant challenges for developers and integrators. These challenges often arise when formatting, displaying, and managing time zones, as well as addressing issues related to local date and time representation, daylight saving time, and other localization concerns. To address these challenges, Hornbill ESP adopts a clearly defined set of rules for handling date and time values. This approach provides a consistent baseline for evaluating and resolving other date and time-related issues. When working with the Hornbill ESP API, it is essential to understand these rules, the design intent, and our specific interpretation of the relevant standards related to date and time representation.

Everything on the Server is in UTC

This is by far the most important single rule to understand. The Hornbill ESP server does the following things with Date/Time values

  • Stores (and retrieves) Date/Time values to/(from) the database
  • Performs date/time value checks, for example to know when a specific time is reached.
  • Performs date/time calculations to determine future/past date/times, time elapsed between dates etc.
  • Event times (reminders/schedules etc) are always calculated in UTC time, but in some cases may require/allow the API user to specify the dat/time value in local time, and provide and accompanying timezone specification that can identify the local time being represented.

The ESP Server service manage date/time values in the database using specific column types, each with a distinct method of handling and storing these values:

  • DATETIME: This column type always represents time in UTC without any adjustments for time zones. All date/time values stored in DATETIME format are standardized to UTC, ensuring consistency across the platform.

  • VARCHAR(2): Date/time values in this column type are generally stored in the ISO8601 format (YYYY-MM-DD HH:MM:SS). However, to enhance readability when viewing raw database data, the ‘T’ and ‘Z’ separators, which are optional in the ISO8601 standard, are omitted. This makes it easier for humans to interpret the data. It’s important to note that VARCHAR values can vary depending on the application or function; they might not always be in UTC but could instead represent local time relative to a specific time zone. In such cases, the documentation for the specific database column will specify the format and time zone in which the date/time value is stored.

INTEGER: For efficiency, some date/time values are stored as Epoch time. This is an integer representation of time, counted in seconds since January 1, 1970, at 00:00:00 UTC. Negative values indicate times before this reference point, while positive values indicate times after it.

Tip

The critical point to understand is that, in general, the Hornbill ESP platform operates exclusively in UTC when dealing with date/time values. The underlying database services are configured to use UTC consistently, ensuring that all date/time operations are standardized and free from the complexities and ambiguities of time zone conversions.

The API and the xs:dateTime type

When defining a date/time value for an input or output parameter of an API we follow the basic international standard for date/time values set out in the ISO8601 specification. This specification covers a wide range of options with date/time formatting which can include Date, Time, Millisecond time, and timezone offsets. . The XML Schema specification for declaring a value a date/time value is xs:dateTime In Hornbill ESP we have adopted a well-defined subset of this specification, specifically this means…

  • Internal Representation and Storage: internal representation and storage of date/time values only has a resolution of seconds, we do not store or represent date/Time values in milliseconds.
  • Timezone Offsets: While the ISO8601 format supports the provision of a timezone offset as part of the date/time string representation, we have specifically excluded this from our supported format. This is primarily because we do not internally represent/store date/time values which includes a TZ offset property, but also its a design decision to remove ambiguity and any expectation that we would store/persist any such additional information.
  • ‘T’ Separators: In the ISO8601 format, if you provide a fully-qualified Date part (YYYY-MM-DD) then the ‘T’ separator is optional, we have opted neither to require it, or allow it. The exclusion of the ‘T’ separator makes the date/time value easier to read for humans in raw format without removing any capability from the date/time representation
  • ‘Z’ Separator: because all date/time values are implicitly representing a UTC time, the ‘Z’ separator is optional. If specified or not, does not matter, it has no meaning being present or not.
  • Always UTC Unless…: any value specified as a xs:dateTime value will always represent a time in UTC, unless Explicitly Stated Otherwise on a case-by-case basis

Date/time values are represented in string form which can have a length of 10-20 characters, Each part above is always represented in a specific fixed character position in the date/time string, with the time parts to the right of the string being incrementally optional in reverse order.

Supported Date/Time (string) Representation:

Part Position Optional Description
YYYY [0-3] No the fully qualified year
- [4] No the hyphen(-) character
MM [5-6] No the month in the range 01 through 12
- [7] No the hyphen(-) character
DD [8-9] No the day of the month in the range 01 through 31
{SPACE} [10] Yes a single space (hex 0x20) character, optional only if HH is specified
HH [11-12] Yes The hour in the range of 00 through 23
: [13] Yes the colon (:) character, optional if MM is specified
MM [14-15] Yes The minute in the range of 00 through 59, optional
: [16] Yes the colon (:) character, optional if MM is specified
SS [17-18] Yes The second in the range of 00 through 59, optional
Z [19] Yes The Z separator character, optional, has no meaning because all xs:dateTime values represent a UTC time onl, may be present or not. All parts provided should always be positioned in their absolute character positions in the teh string value.

This is an example of a fully-qualified Date/Time value represented as a string: 2018-03-19 12:45:10Z

Example Date/Time formatted string values

Value Valid Explanation
2024-01-02 Yes Is interpreted as 2024-01-02 00:00:00Z
2024-01-02 Yes Is interpreted as 2024-01-02 00:00:00, The Z separator is optional so does not need to be provided.
2024-01-02 11 Yes Is interpreted as 2024-01-02 11:00:00Z
2024 No You must provide at least the date part YYYY-MM-DD
2024-01-02 11:22 Yes Is interpreted as 2024-01-02 11:22:00Z
2024-01-02 11:88 No The minutes (MM) is out of range, should be 00-59`
2024-01-02 4:30 No The hour (HH) not valid, it must always be exactly two digits in the 11th an d 12th character potion and must be in the range of 00-23`
2024-01-02T04:30:15Z No The T separator is not supported and should not be included

Working with Timezones

Generally speaking, users of the system will expect to see date/time values represented in their local time. Because we always work with date/time values in UTC time, it is the responsibility of the front end applications and presentations of date/time values to represent date/timed to the users local timezone and locale formatting as required. This is typical for any system designed to operate globally in multiple timezones at the same time. By following this simple rule, there is no ambiguity around how we should be handling date/time values in any given situation.

However, there are many functions and services provided by the Hornbill ESP platform to help working with date.time values, this includes in some cases working with local times. In these cases, date/time values are still represented in UTC time, but, the API’s and operations will additionally include the option for you to specify a timezone to work in.

Take the example of using an API to determine a future date/time based on the users current time, for example, to schedule a report to run. The user would expect the time to run to be specified in their local time. The API would expect the time to be specified either in UTC, but could instead require the date/time value to be specified in local time, and to have a timezone provided, so that the server can determine the exact UTC time for internal representation and storage. Each API parameter that takes a date/time value will specify the exact requirements, of not specified then you should always assume UTC, even if you are also required to provide a specific timezone as well.

In This Document