diff --git a/timezone/config/tzinfo b/timezone/config/tzinfo new file mode 100644 index 00000000..36162155 Binary files /dev/null and b/timezone/config/tzinfo differ diff --git a/timezone/test.csv b/timezone/test.csv new file mode 100644 index 00000000..bde2d2c5 --- /dev/null +++ b/timezone/test.csv @@ -0,0 +1,11 @@ +action,ms,bytes,lang,code,repeat,minver,comment +before,0,0,q,.timezone.init[],1,,Initialize package +true,0,0,q,0=10170056837; + tz:update gmtDateTime:12h$-946684800000000000+gmtDateTime*1000000000 from tz; + tz:update gmtOffset:16h$gmtOffset*1000000000 from tz; + tz:update localDateTime:gmtDateTime+gmtOffset from tz; + tz:`gmtDateTime xasc tz; + tz:update `g#timezoneID from tz; + tz + }; + +/ convert from local timestamp to gmt +.timezone.gmttolocal:{[tz;ts] + if[not (tz:`$tz) in .timezone.zones;'`notValidTimezone]; + $[0>type ts;first;(::)]@exec gmtDateTime+gmtOffset from aj[`timezoneID`gmtDateTime;([]timezoneID:(),tz;gmtDateTime:ts,());.timezone.offsets] + }; + +/ convert from gmt to local timestamp +.timezone.localtogmt:{[tz;ts] + if[not (tz:`$tz) in .timezone.zones;'`notValidTimezone]; + $[0>type ts;first;(::)]@exec localDateTime-gmtOffset from aj[`timezoneID`localDateTime;([]timezoneID:(),tz;localDateTime:ts,());.timezone.offsets] + }; + +/ convert between custom timestamps +.timezone.convert:{[stz;dtz;ts].timezone.gmttolocal[dtz;.timezone.localtogmt[stz;ts]]}; + +/ init function to read in timezone source data +.timezone.init:{ + .timezone.offsets:@[.timezone.config.read;`;{'`cantImportTimeZoneData}]; + .timezone.zones:exec distinct timezoneID from .timezone.offsets; + };