Without disagreeing in any way that the most direct thing to do is E.setTimeZone(amt, name), I took a few more steps down the rabbit hole of looking at scheduled DST changes. It seems there are some peculiarities baked into E.setDST()? First, it already has 12 parameters(!), which means that unlike E.setTimeZone() it can't straightforwardly take optional time zone name parameters at the end. Second, to the point of not breaking existing uses, it appears from reading the code that widdst depends on the fact that setDSTdisablessetTimeZone to prevent further host time zone updates, and thus relies on the host not calling setDST, since that would break the override.
So … one might wish that the entry had been setDST(base, delta, startRule, endRule) where startRule and endRule are arrays, for example. And while preventing automatic updates is a sensible idea, it might be better to have said Bangle.setEnableAutomaticTimezone(false) explicitly, rather than accomplishing it by implicitly disabling setTimeZone.
It seems wrong to set up a competing version of setDST, but then again it seems—if my reading of the code is correct, of course—that widdst is relying on being the sole user of the call!
Given this, I can imagine several ways forward to ‘rescue’ on-device DST processing, each slightly ugly in its own way:
Change the interface of setDST breakingly, updating any clients that use it, and split off an explicit setEnableAutomaticTimezone() entrypoint;
Keep all existing entrypoints unchanged and add a new one that allows setting DST under a slightly different interface, while (like setTimeZone) being implicitly disabled by setDST;
Extend setTimeZone so that it takes an optional label and optional rules to schedule changes (again while maintaining the peculiar interaction with setDST, now exactly as documented);
Like (2) or (3), but adding the explicit override mechanism from (1).
What, if anything, would you like for your baby? :) I'm a bit sad to give up prospective DST advice, but if your response is just to leave it and go with the minimal thing, I'll live. ;)
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hey, Gordon.
Without disagreeing in any way that the most direct thing to do is
E.setTimeZone(amt, name)
, I took a few more steps down the rabbit hole of looking at scheduled DST changes. It seems there are some peculiarities baked intoE.setDST()
? First, it already has 12 parameters(!), which means that unlikeE.setTimeZone()
it can't straightforwardly take optional time zone name parameters at the end. Second, to the point of not breaking existing uses, it appears from reading the code that widdst depends on the fact thatsetDST
disablessetTimeZone
to prevent further host time zone updates, and thus relies on the host not callingsetDST
, since that would break the override.So … one might wish that the entry had been
setDST(base, delta, startRule, endRule)
wherestartRule
andendRule
are arrays, for example. And while preventing automatic updates is a sensible idea, it might be better to have saidBangle.setEnableAutomaticTimezone(false)
explicitly, rather than accomplishing it by implicitly disablingsetTimeZone
.It seems wrong to set up a competing version of
setDST
, but then again it seems—if my reading of the code is correct, of course—that widdst is relying on being the sole user of the call!Given this, I can imagine several ways forward to ‘rescue’ on-device DST processing, each slightly ugly in its own way:
setDST
breakingly, updating any clients that use it, and split off an explicitsetEnableAutomaticTimezone()
entrypoint;setTimeZone
) being implicitly disabled bysetDST
;setTimeZone
so that it takes an optional label and optional rules to schedule changes (again while maintaining the peculiar interaction withsetDST
, now exactly as documented);What, if anything, would you like for your baby? :) I'm a bit sad to give up prospective DST advice, but if your response is just to leave it and go with the minimal thing, I'll live. ;)