I have a flow which runs daily at 1am, setting some parameters for local time 9am to 5pm.
However, when daylight savings time ends the time goes to 8am to 4pm.
I am currently manually editing the times come DST, but thought there might be a way to automate it part of the flow.
AUS DST starts on the first Sunday in October 2am and ends on the first Sunday in April 3pm.
What I am trying to do is create two variables: StartTimeUTC
and EndTimeUTC
with one of the 9am to 5pm UTC times:
Then I would update this variable if DST starts or ends to a new hardcoded +/- hour.
I thought a good way to do this is with a condition, and if the DST time is true then update those two variables with the new HH value, otherwise do nothing. But I'm finding it hard to know what parameters it should be.
My questions are:
My conditional at the moment (before I got stuck) was:
formatDate(utcNow(), 'dd') <= 07 // is it in the first week
formatDate(utcNow(), 'MM') == 04 // is it April
formatDate(utcNow(), 'ddd') == Sun // is it Sunday
formatDate(utcNow(), 'dd') <= 07 // is it in the first week
formatDate(utcNow(), 'MM') == 10 // is it October
formatDate(utcNow(), 'ddd') == Sun // is it Sunday
But this is wrong because it only would run on the first Sunday in April AND the first Sunday in October, so it would always be false (since the date will never be at two places at once).
If I update it so it is greater than "04" and less than "10" for the months, then it only runs on Sundays between April and October.
At best I can only get it to work if I set it to check if it is greater and "04" and less than "10" so it runs true everyday between April and October. However, if in April the first Sunday (when DST ends) is the 7th of the month, then I would have 6 days of incorrect time in the variable. The same occurs of October.
The other way you might be able to do this is to use the dateDifference
expression and then evaluate the amount of hours that is resulting.
If you're in Sydney, 11 hours would indicate that it's DST and 10 would indicate that it's not.
This is a flow that shows the thinking ...
Initialize UTC Now
... utcNow()
Initialize Sydney Now ... convertFromUtc(variables('UTC Now'), 'AUS Eastern Standard Time')
Hours Difference ... int(first(split(dateDifference(variables('UTC Now'), variables('Sydney Now')), ':')))
From there, you can set a variable (e.g. Is DST
) to be true if the value equals 11.
Initialize UTC Now Expression = addDays(utcNow(), -150)
Initialize UTC Now Expression = utcNow()