I have a skin that retrieves an Unix timestamp from a website. I'm trying to convert this to the regular Windows time but it's not showing the time in my timezone (GMT+8):
ZipD wrote: ↑January 14th, 2024, 10:31 pm
I have a skin that retrieves an Unix timestamp from a website. I'm trying to convert this to the regular Windows time but it's not showing the time in my timezone (GMT+8):
I'm not home to can give it a try, so am not entirely sure, however here is a start point, I think, but involves a lua script. If you can't deal with this, later when I get home, will try to implement it.
Just to clarify, do your measures in the the About > Skins tab correctly get the data and calculate things? Also, is your problem the fact that the Unix time is not displayed at all, or is the fact that it's displayed alright just not adjusted to your timezone?
It's displayed as intended but not automatically adjusted to my timezone. If I were to correct it manually, I could add 28,800 seconds to it. I just wondered why it would not automatically adjust.
ZipD wrote: ↑January 15th, 2024, 1:05 pm
It's displayed as intended but not automatically adjusted to my timezone. If I were to correct it manually, I could add 28,800 seconds to it. I just wondered why it would not automatically adjust.
I see. Maybe the note here explains better why automatic adjustment doesn't happen. I believe you'd have to set the TimeZone option in your Time measure to adjust the outcome, but yeah, setting that option is not exactly automatic.
ZipD wrote: ↑January 15th, 2024, 1:05 pm
It's displayed as intended but not automatically adjusted to my timezone. If I were to correct it manually, I could add 28,800 seconds to it. I just wondered why it would not automatically adjust.
It seems when a TimeStamp option is defined on a Time measure, the TimeZone option has no effect on the measure. This probably is completely normal, if you defined the time stamp, the time zone doesn't matter anymore.
The solution in my opinion is indeed what you figured out: to add 28800 (8 hours) to the sum calculated by the [MeasureUnixTimeToWindowsTime] measure, by altering its Formula option: Formula=( [MeasureWorldBossSpawnTime:] + 11644473600 + 8 * 3600 ).
ZipD wrote: ↑January 15th, 2024, 1:05 pm
It's displayed as intended but not automatically adjusted to my timezone. If I were to correct it manually, I could add 28,800 seconds to it. I just wondered why it would not automatically adjust.
On a second thought, you might want to use a SysInfo measure to get your system timezone automatically (check out the Timezone Values on this page): https://docs.rainmeter.net/manual/measures/sysinfo/
The value is in minutes though, so you should take that into account when calculating things.
For a more complex case, where the DST for any past, present or future date is also concerned, take look here: https://forum.rainmeter.net/viewtopic.php?t=39016#p200725
You probably don't need all that, but it illustrates the principle / approach / formulas quite well.