Skip to content
Jas edited this page Aug 7, 2019 · 1 revision

Timezone Conversion Library

This library provides timezone conversion functions as described at https://code.kx.com/v2/kb/timezones/.

By default, when the library is initialised (via .tz.init) it assumes the configuration file lives within a config/timezone folder from the root folder defined by the require library (.require.location.root). Set .tz.cfg.csvPath to override this functionality.

.tz.getSupportedTimezones

Returns all the available timezones as defined in the configuration.

q) .tz.getSupportedTimezones[]
`u#`Etc/GMT-14`Asia/Anadyr`Etc/GMT-13`Pacific/Tongatapu`NZ-CHAT`Pacific/Chath..

.tz.utcToTimezone

Converts a timestamp assumed to be in UTC into the specified timezone. This function accepts an atom or list of timestamps to convert.

/ Atom timestamp and daylight savings based on the date
q) .tz.utcToTimezone[2018.08.07 + 23:00:00; `$"Europe/London"]
2018.08.08D00:00:00.000000000

/ Timestamp list and no daylight savings based on the date
q) .tz.utcToTimezone[2018.12.25 + 23:00:00 23:00:01; `$"Europe/London"]
2018.12.25D23:00:00.000000000 2018.12.25D23:00:01.000000000

.tz.timezoneToUtc

Converts a timestamp in the specified timezone into a UTC-based time. This function accepts an atom or list of timestamps to convert.

/ Atom timestamp and daylight savings based on the date
q) .tz.timezoneToUtc[`timestamp$2018.08.08; `$"Europe/London"]
2018.08.07D23:00:00.000000000

/ Timestamp list and no daylight savings based on the date
q) .tz.timezoneToUtc[2018.12.25 + 23:00:00 23:00:01; `$"Europe/London"]
2018.12.25D23:00:00.000000000 2018.12.25D23:00:01.000000000

.tz.timezoneToTimezone

Converts a timestamp in the specified timezone to another specified timezone. This function accepts an atom or list of timestamps to convert.

/ Atom timestamp and summer time for London and New York
q) .tz.timezoneToTimezone[`timestamp$2018.08.07; `$"Europe/London"; `$"America/New_York"]
2018.08.06D19:00:00.000000000

/ Timestamp list and New York summer time start
q) .tz.timezoneToTimezone[`timestamp$2018.03.11 2018.03.12; `$"Europe/London"; `$"America/New_York"]
2018.03.10D19:00:00.000000000 2018.03.11D20:00:00.000000000
Clone this wiki locally