Quantcast
Channel: Rainmeter Forums
Viewing all articles
Browse latest Browse all 974

Windows Time Zones (PowerShell + Lua)

$
0
0
I'd like to share a ps1 script to get all windows timezone data from the registry into a lua table, plus a lua script to read that table to use the information.

We get the timezone name and display, std and dst offsets as well as current offset in hours, dst start and end date strings, booleans to know if the time zone has dst or not, and if it is currently active or not.

Note: This won't work to make a World Clock given that windows time zones are not directly related to all locations. However, this can work to let the user choose a timezone manually from a drop down menu, offline.

Timezone information is updated by Windows Update. You need to have the latest updates installed to make sure the information is up to date.

Here's a test skin.
Captura de pantalla 2025-05-14 143330.png
WindowsTimeZones_1.1.1.rmskin

After loading the skin, click anywhere to run the script and generate the lua table, it will then refresh. Scroll to change time zones.
The skin shows the selected timezone info, as well as UTC, Local and Zone clocks.
Local time is that of your machine.
Zone time is that of the selected time zone. It has the current offset (either std or dst) for the selected zone already applied.
Is DST Active boolean is UTC based.
DST Start and End time strings are in that zone's timezone.
For example, for Central Europe Standard Time:
STD Offset = 1
DST Offset = 2
DST Start is: 2025-03-30T02:00, which corresponds to 2025-03-30T:01:00 UTC (- STD offset).
DST End is: 2025-10-26T03:00, which corresponds to 2025-10-26T01:00 UTC (- DST offset).
Difference is the time difference in hours between the local time and the zone time.

You can compare the clocks to those shown on timeanddate.com

Edit.

Changes:
Added execution policy bypass for users with restricted script execution.
Now the table is sorted by std offset and alphabetically to match windows timezone drop down menus.
Added DaylightSavingTime=0 to [UTCTime] measure to account for locations with dst active.

Statistics: Posted by RicardoTM — Yesterday, 8:39 pm — Replies 14 — Views 1264



Viewing all articles
Browse latest Browse all 974

Trending Articles