diff --git a/core/time/time.odin b/core/time/time.odin index 93fa7f8b3..6500d7c93 100644 --- a/core/time/time.odin +++ b/core/time/time.odin @@ -127,8 +127,17 @@ clock :: proc(t: Time) -> (hour, min, sec: int) { -ABSOLUTE_ZERO_YEAR :: -292277022399; // Day is chosen so that 2001-01-01 is Monday in the calculations -UNIX_TO_ABSOLUTE :: (1969*365 + 1969/4 - 1969/100 + 1969/400 - ((ABSOLUTE_ZERO_YEAR - 1) * 365.2425)) * SECONDS_PER_DAY; +ABSOLUTE_ZERO_YEAR :: i64(-292277022399); // Day is chosen so that 2001-01-01 is Monday in the calculations +ABSOLUTE_TO_INTERNAL :: i64(-9223371966579724800); // i64((ABSOLUTE_ZERO_YEAR - 1) * 365.2425 * SECONDS_PER_DAY); +INTERNAL_TO_ABSOLUTE :: i64(-ABSOLUTE_TO_INTERNAL); + +UNIX_TO_INTERNAL :: i64((1969*365 + 1969/4 - 1969/100 + 1969/400) * SECONDS_PER_DAY); +INTERNAL_TO_UNIX :: i64(-UNIX_TO_INTERNAL); + +WALL_TO_INTERNAL :: i64((1884*365 + 1884/4 - 1884/100 + 1884/400) * SECONDS_PER_DAY); +INTERNAL_TO_WALL :: i64(- WALL_TO_INTERNAL); + +UNIX_TO_ABSOLUTE :: i64(UNIX_TO_INTERNAL + INTERNAL_TO_ABSOLUTE); _is_leap_year :: proc(year: int) -> bool { return year%4 == 0 && (year%100 != 0 || year%400 == 0); diff --git a/core/time/time_windows.odin b/core/time/time_windows.odin index c1d766aee..32b930065 100644 --- a/core/time/time_windows.odin +++ b/core/time/time_windows.odin @@ -9,11 +9,9 @@ now :: proc() -> Time { win32.get_system_time_as_file_time(&file_time); - quad := u64(file_time.lo) | u64(file_time.hi) << 32; + ft := i64(u64(file_time.lo) | u64(file_time.hi) << 32); - UNIX_TIME_START :: 0x019db1ded53e8000; - - ns := (1e9/1e7)*(i64(quad) - UNIX_TIME_START); + ns := (ft - 0x019db1ded53e8000) * 100; return Time{_nsec=ns}; }