Add Times-scripts/setTimeZone.txt

This commit is contained in:
Dejan 2026-02-21 09:44:20 +00:00
parent 69afb5c9b4
commit 7aa2aab4cf

View file

@ -0,0 +1,46 @@
VAR
stTimezone : STRUCT
bias : INT; // Base offset in minutes (e.g. 60 for CET)
standardName : STRING[4]; // e.g. 'CET'
standardBias : INT; // Usually 0
daylightName : STRING[4]; // e.g. 'CEST'
daylightBias : INT := -60; // DST offset relative to standard (usually -60 min)
standardDate : STRUCT // When to switch back to standard (Oct)
month : USINT := 10;
day : USINT; // 0 = Sunday
hour : USINT := 3;
week : USINT := 5; // 5 = last week
END_STRUCT;
daylightDate : STRUCT // When to switch to DST (March)
month : USINT := 3;
day : USINT;
hour : USINT := 2;
week : USINT := 5;
END_STRUCT;
END_STRUCT;
END_VAR
// Example: Set Europe/CET rules (last Sunday March/October)
stTimezone.bias := 60; // UTC+1 standard
stTimezone.standardBias := 0;
stTimezone.daylightBias := -60; // +1 hour during DST
stTimezone.standardName := 'CET';
stTimezone.daylightName := 'CEST';
// Standard → DST: last Sunday March at 02:00 local → clocks forward
stTimezone.daylightDate.month := 3;
stTimezone.daylightDate.week := 5; // 5 = last week
stTimezone.daylightDate.day := 0; // 0 = Sunday
stTimezone.daylightDate.hour := 2;
// DST → Standard: last Sunday October at 03:00 local → clocks back
stTimezone.standardDate.month := 10;
stTimezone.standardDate.week := 5;
stTimezone.standardDate.day := 0;
stTimezone.standardDate.hour := 3;
SET_TIMEZONE(
TIMEZONE := stTimezone,
RET_VAL => wRetVal, // 0 = OK
STATUS => wStatus
);