Initial cut of timezones

This commit is contained in:
Colin Davidson
2024-12-01 11:54:50 +11:00
committed by flysand7
parent b7e61095a9
commit fc9983e9c8
9 changed files with 1627 additions and 6 deletions
+44 -1
View File
@@ -77,12 +77,55 @@ Time :: struct {
nano: i32,
}
TZ_Record :: struct {
time: i64,
utc_offset: i64,
shortname: string,
dst: bool,
}
TZ_Date_Kind :: enum {
NoLeap,
Leap,
MonthWeekDay,
}
TZ_Transition_Date :: struct {
type: TZ_Date_Kind,
month: u8,
week: u8,
day: u16,
time: i64,
}
TZ_RRule :: struct {
has_dst: bool,
std_name: string,
std_offset: i64,
std_date: TZ_Transition_Date,
dst_name: string,
dst_offset: i64,
dst_date: TZ_Transition_Date,
}
TZ_Region :: struct {
name: string,
records: []TZ_Record,
shortnames: []string,
rrule: TZ_RRule,
}
/*
A type representing datetime.
*/
DateTime :: struct {
using date: Date,
using time: Time,
tz: ^TZ_Region,
}
/*
@@ -130,4 +173,4 @@ Weekday :: enum i8 {
}
@(private)
MONTH_DAYS :: [?]i8{-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
MONTH_DAYS :: [?]i8{-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}