How To Determine if You're In Daylight Saving Time?
Tuesday, 28 June 2022 · 2 messages · last reply 29 Jun 2022
EK
Eliot Kimber28 Jun 2022 18:12 #
I’m showing times on RESTXQ generated pages that need to be adjusted for a particular time zone. Doing the time zone adjustment is easy enough but I realized that knowing whether or not a given time zone should be standard or daylight time is a challenge not directly addressed by the XQuery time functions.
So my question: does anyone have a technique for determining if a given time zone or region is using DST?
Of course I can hard-code some sort of DST calendar for the time zones I know I need (U.S. time zones, European Central Time, India Standard Time) but it seemed like there ought to be a more general solution somewhere.
My server is running on Linux but is developed and tested on macOS.
Thanks,
Eliot
_____________________________________________
Eliot Kimber
Sr Staff Content Engineer
O: 512 554 9368
M: 512 554 9368
servicenow.com<https://www.servicenow.com>
LinkedIn<https://www.linkedin.com/company/servicenow> | Twitter<https://twitter.com/servicenow> | YouTube<https://www.youtube.com/user/servicenowinc> | Facebook<https://www.facebook.com/servicenow>
LQ
Liam R. E. Quin29 Jun 2022 02:08 #
Quoted text · Eliot Kimber · 4 lines
On Tue, 2022-06-28 at 16:12 +0000, Eliot Kimber wrote: > > So my question: does anyone have a technique for determining if a > given time zone or region is using DST?
Is currently using? The transition dates are in at least some cases political, and set by parliaments or whatever each year.
Quoted text · Eliot Kimber · 2 lines
> > My server is running on Linux but is developed and tested on macOS.
You could run the system command, e.g.
LC_TIME="fc_CA.UTF-8" date
which here returns
mar 28 jun 2022 17:38:41 EDT
but that depends on having the locale installed and up to date.
We also don't have in XQuery or XSLT or Xpath a way to interpret "The thurd sunday in March" which is when, for example, Cuba switches.
I'm not sure if tehre's a machine-readable definitive list somewhere but seems possible...
--
Liam Quin, https://www.delightfulcomputing.com/
Available for XML/Document/Information Architecture/XSLT/
XSL/XQuery/Web/Text Processing/A11Y training, work & consulting. Barefoot Web-slave, antique illustrations: http://www.fromoldbooks.org
Written for BaseX 9.7. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery