Time zone v0.1.0

Source
The system's time zone rules, read through GetTimeZoneInformation.

TimeZoneRuleDate

pub struct TimeZoneRuleDate {
    pub year: uint16;
    pub month: uint16;
    pub dayOfWeek: uint16;
    pub day: uint16;
    pub hour: uint16;
    pub minute: uint16;
    pub second: uint16;
    pub milliseconds: uint16;
}

When a time-zone rule takes effect, in the layout of SYSTEMTIME but read as a rule, not a date. A rule with year zero recurs every year: in month, on the dayth occurrence of dayOfWeek (Sunday is zero), where the fifth occurrence means the last, at hour:minute local time. A zero month means the zone has no daylight time.

See also: https://learn.microsoft.com/en-us/windows/win32/api/timezoneapi/ns-timezoneapi-time_zone_information

Source

Fields

NameTypeDescription
yearuint16The year for a one-time change, or zero for a rule that recurs.
monthuint16The month, 1 through 12, or zero when there is no change.
dayOfWeekuint16The day of the week, Sunday being zero.
dayuint16Which occurrence of that day in the month, 1 through 5, where 5 is the last.
houruint16The hour of the change, in the local time before it.
minuteuint16The minute of the change.
seconduint16The second of the change.
millisecondsuint16The millisecond of the change.

TimeZoneInformation

pub struct TimeZoneInformation {
    pub bias: int32;
    pub standardName: uint16[N];
    pub standardDate: TimeZoneRuleDate;
    pub standardBias: int32;
    pub daylightName: uint16[N];
    pub daylightDate: TimeZoneRuleDate;
    pub daylightBias: int32;
}

Win32's TIME_ZONE_INFORMATION: a zone's offsets and when its daylight time starts and ends. Each bias is minutes to add to local time to get UTC, so a zone east of Greenwich has a negative one.

See also: https://learn.microsoft.com/en-us/windows/win32/api/timezoneapi/ns-timezoneapi-time_zone_information

Source

Fields

NameTypeDescription
biasint32The bias of standard time, in minutes.
standardNameuint16[N]The name of standard time, NUL-terminated UTF-16.
standardDateTimeZoneRuleDateWhen standard time starts.
standardBiasint32What is added to bias during standard time, usually zero.
daylightNameuint16[N]The name of daylight time, NUL-terminated UTF-16.
daylightDateTimeZoneRuleDateWhen daylight time starts.
daylightBiasint32What is added to bias during daylight time, usually -60.

GetTimeZoneInformation

pub extern func GetTimeZoneInformation(information: *var TimeZoneInformation) -> uint32

Reads the system's current time zone.

See also: https://learn.microsoft.com/en-us/windows/win32/api/timezoneapi/nf-timezoneapi-gettimezoneinformation

Source

Parameters

NameTypeDescription
information*var TimeZoneInformationreceives the zone

Returns: which part of the year it is now, or 0xFFFFFFFF on failure with the reason in GetLastError