It is currently September 15th, 2019, 8:59 pm

[Bug] Time measure's UTC offset is incorrect

Report bugs with the Rainmeter application and suggest features.
User avatar
JelleDekkers
Posts: 21
Joined: September 27th, 2017, 6:32 pm

[Bug] Time measure's UTC offset is incorrect

JelleDekkers » September 8th, 2019, 7:47 am

Just a simple time measure, right?

Code: Select all

[MeasureTimeZone]
Measure=Time
Format=%z
I live in the Netherlands and the current UTC offset is +0200 because of DST. During the winter, it's +0100. However, this measure outputs +0100 instead of +0200. I believe it's because Window's time zone is set to +1, which isn't the same as the UTC offset since UTC doesn't care about DST.
User avatar
dvo
Posts: 541
Joined: February 7th, 2016, 6:08 am

Re: [Bug] Time measure's UTC offset is incorrect

dvo » September 8th, 2019, 8:48 am

:Whistle sorry i'm not shure about this ... i will let it over to the pro's :welcome: nederlands is niet zo lastig toch :P...
( english..btw dutch isn't that difficult :P)
Last edited by dvo on September 8th, 2019, 2:09 pm, edited 1 time in total.
User avatar
jsmorley
Developer
Posts: 19440
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [Bug] Time measure's UTC offset is incorrect

jsmorley » September 8th, 2019, 1:10 pm

Correct. The %z time format code does not take into account Daylight Saving Time, as that is purely a local affectation, and has nothing to do with the standard offset from UTC.
User avatar
jsmorley
Developer
Posts: 19440
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [Bug] Time measure's UTC offset is incorrect

jsmorley » September 8th, 2019, 1:29 pm

You can use the TimeZone features of the SysInfo plugin to resolve this:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]

[MeasureIsDST]
Measure=Plugin
Plugin=SysInfo
SysInfoType=TIMEZONE_ISDST
IfCondition=MeasureIsDST < 1
IfTrueAction=[!SetOption MeasureTotalOffset Formula "Neg(MeasureStandardOffset / 60)"]
IfFalseAction=[!SetOption MeasureTotalOffset Formula "Neg((MeasureStandardOffset + MeasureDaylightOffset)/60)"]

[MeasureStandardOffset]
Measure=Plugin
Plugin=SysInfo
SysInfoType=TIMEZONE_BIAS

[MeasureDaylightOffset]
Measure=Plugin
Plugin=SysInfo
SysInfoType=TIMEZONE_DAYLIGHT_BIAS

[MeasureTotalOffset]
Measure=Calc

[MeterOffset]
Meter=String
MeasureName=MeasureTotalOffset
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=Local time is %1:00 hours from UTC

1.jpg


2.jpg


I use the Neg() function to turn the result from the default, where it is the amount of minutes "from" the local time "to" UTC, into the amount of minutes "from" UTC "to" the local time.

I'm in the Eastern Time Zone in the US, which is currently in Daylight Saving Time and so the standard offset of -5:00 hours from UTC is currently -4:00 hours.

This gets a little trickier in the few places where the standard offset is not some even number of hours, but that can be solved as well, though I'm not going down that rabbit hole unless you really need me to. Just means you have to turn it all into "seconds" and do some additional stuff to turn seconds into hours and minutes. You don't want 4.5 hours, but 4:30 hours.

https://www.timeanddate.com/time/dst/
You do not have the required permissions to view the files attached to this post.