package core:time

⌘K
Ctrl+K
or
/

    Types

    Benchmark_Error ¶

    Benchmark_Error :: enum int {
    	Okay             = 0, 
    	Allocation_Error, 
    }
    Related Procedures With Returns

    Benchmark_Options ¶

    Benchmark_Options :: struct {
    	setup:                proc(options: ^Benchmark_Options, allocator := context.allocator) -> (err: Benchmark_Error),
    	bench:                proc(options: ^Benchmark_Options, allocator := context.allocator) -> (err: Benchmark_Error),
    	teardown:             proc(options: ^Benchmark_Options, allocator := context.allocator) -> (err: Benchmark_Error),
    	rounds:               int,
    	bytes:                int,
    	input:                []u8,
    	count:                int,
    	processed:            int,
    	output:               []u8,
    	// Unused for hash benchmarks
    	hash:                 u128,
    	// 		Performance
    	duration:             Duration,
    	rounds_per_second:    f64,
    	megabytes_per_second: f64,
    }
    Related Procedures With Parameters

    Month ¶

    Month :: enum int {
    	January   = 1, 
    	February, 
    	March, 
    	April, 
    	May, 
    	June, 
    	July, 
    	August, 
    	September, 
    	October, 
    	November, 
    	December, 
    }
    Related Procedures With Returns

    Stopwatch ¶

    Stopwatch :: struct {
    	running:       bool,
    	_start_time:   Tick,
    	_accumulation: Duration,
    }
    Related Procedures With Parameters

    Tick ¶

    Tick :: struct {
    	_nsec: i64,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    Weekday ¶

    Weekday :: enum int {
    	Sunday    = 0, 
    	Monday, 
    	Tuesday, 
    	Wednesday, 
    	Thursday, 
    	Friday, 
    	Saturday, 
    }
    Related Procedures With Returns

    Constants

    ABSOLUTE_TO_INTERNAL ¶

    ABSOLUTE_TO_INTERNAL :: i64(-9223371966579724800)
     

    i64((ABSOLUTE_ZERO_YEAR - 1) 365.2425 SECONDS_PER_DAY);

    ABSOLUTE_TO_UNIX ¶

    ABSOLUTE_TO_UNIX: i64 : -UNIX_TO_ABSOLUTE

    ABSOLUTE_ZERO_YEAR ¶

    ABSOLUTE_ZERO_YEAR :: i64(-292277022399)
     

    Day is chosen so that 2001-01-01 is Monday in the calculations

    DAYS_PER_100_YEARS ¶

    DAYS_PER_100_YEARS :: 365 * 100 + 24

    DAYS_PER_400_YEARS ¶

    DAYS_PER_400_YEARS :: 365 * 400 + 97

    DAYS_PER_4_YEARS ¶

    DAYS_PER_4_YEARS :: 365 * 4 + 1

    Hour ¶

    Hour: Duration : 60 * Minute

    INTERNAL_TO_ABSOLUTE ¶

    INTERNAL_TO_ABSOLUTE: i64 : -ABSOLUTE_TO_INTERNAL

    INTERNAL_TO_UNIX ¶

    INTERNAL_TO_UNIX: i64 : -UNIX_TO_INTERNAL

    INTERNAL_TO_WALL ¶

    INTERNAL_TO_WALL: i64 : -WALL_TO_INTERNAL

    IS_SUPPORTED ¶

    IS_SUPPORTED :: _IS_SUPPORTED

    MAX_DURATION ¶

    MAX_DURATION :: Duration(1 << 63 - 1)

    MIN_DURATION ¶

    MIN_DURATION :: Duration(-1 << 63)

    Microsecond ¶

    Microsecond: Duration : 1000 * Nanosecond

    Millisecond ¶

    Millisecond: Duration : 1000 * Microsecond

    Minute ¶

    Minute: Duration : 60 * Second

    Nanosecond ¶

    Nanosecond :: Duration(1)

    SECONDS_PER_DAY ¶

    SECONDS_PER_DAY :: 24 * SECONDS_PER_HOUR

    SECONDS_PER_HOUR ¶

    SECONDS_PER_HOUR :: 60 * SECONDS_PER_MINUTE

    SECONDS_PER_MINUTE ¶

    SECONDS_PER_MINUTE :: 60

    SECONDS_PER_WEEK ¶

    SECONDS_PER_WEEK :: 7 * SECONDS_PER_DAY

    Second ¶

    Second: Duration : 1000 * Millisecond

    UNIX_TO_ABSOLUTE ¶

    UNIX_TO_ABSOLUTE: i64 : UNIX_TO_INTERNAL + INTERNAL_TO_ABSOLUTE

    UNIX_TO_INTERNAL ¶

    UNIX_TO_INTERNAL :: i64((1969 * 365 + 1969 / 4 - 1969 / 100 + 1969 / 400) * SECONDS_PER_DAY)

    WALL_TO_INTERNAL ¶

    WALL_TO_INTERNAL :: i64((1884 * 365 + 1884 / 4 - 1884 / 100 + 1884 / 400) * SECONDS_PER_DAY)

    Variables

    days_before ¶

    @(rodata)
    days_before: [13]i32 = …

    Procedures

    SCOPED_TICK_DURATION ¶

    SCOPED_TICK_DURATION :: proc "contextless" (d: ^Duration) -> Tick {…}

    accurate_sleep ¶

    accurate_sleep :: proc "contextless" (d: Duration) {…}
     

    Accurate sleep borrowed from: https://blat-blatnik.github.io/computerBear/making-accurate-sleep-function/

    Accuracy seems to be pretty good out of the box on Linux, to within around 4µs worst case. On Windows it depends but is comparable with regular sleep in the worst case. To get the same kind of accuracy as on Linux, have your program call windows.timeBeginPeriod(1) to tell Windows to use a more accurate timer for your process. Additionally your program should call windows.timeEndPeriod(1) once you're done with accurate_sleep.

    benchmark ¶

    benchmark :: proc(options: ^Benchmark_Options, allocator := context.allocator) -> (err: Benchmark_Error) {…}

    clock_from_duration ¶

    clock_from_duration :: proc "contextless" (d: Duration) -> (hour, min, sec: int) {…}

    clock_from_seconds ¶

    clock_from_seconds :: proc "contextless" (nsec: u64) -> (hour, min, sec: int) {…}

    clock_from_stopwatch ¶

    clock_from_stopwatch :: proc "contextless" (s: Stopwatch) -> (hour, min, sec: int) {…}

    clock_from_time ¶

    clock_from_time :: proc "contextless" (t: Time) -> (hour, min, sec: int) {…}

    components_to_time ¶

    components_to_time :: proc "contextless" (
    	#any_int year, #any_int month, #any_int day, #any_int hour, #any_int minute, #any_int second: i64, 
    	#any_int nsec:                          i64 = i64(0), 
    ) -> (t: Time, ok: bool) {…}

    compound_to_time ¶

    compound_to_time :: proc "contextless" (datetime: datetime.DateTime) -> (t: Time, ok: bool) {…}

    date ¶

    date :: proc "contextless" (t: Time) -> (year: int, month: Month, day: int) {…}

    day ¶

    day :: proc "contextless" (t: Time) -> (day: int) {…}

    diff ¶

    diff :: proc "contextless" (start, end: Time) -> Duration {…}

    duration_hours ¶

    duration_hours :: proc "contextless" (d: Duration) -> f64 {…}

    duration_microseconds ¶

    duration_microseconds :: proc "contextless" (d: Duration) -> f64 {…}

    duration_milliseconds ¶

    duration_milliseconds :: proc "contextless" (d: Duration) -> f64 {…}

    duration_minutes ¶

    duration_minutes :: proc "contextless" (d: Duration) -> f64 {…}

    duration_nanoseconds ¶

    duration_nanoseconds :: proc "contextless" (d: Duration) -> i64 {…}

    duration_round ¶

    duration_round :: proc "contextless" (d, m: Duration) -> Duration {…}

    duration_seconds ¶

    duration_seconds :: proc "contextless" (d: Duration) -> f64 {…}

    duration_truncate ¶

    duration_truncate :: proc "contextless" (d, m: Duration) -> Duration {…}

    from_nanoseconds ¶

    from_nanoseconds :: proc "contextless" (nsec: i64) -> Time {…}

    has_invariant_tsc ¶

    has_invariant_tsc :: proc "contextless" () -> bool {…}

    is_leap_year ¶

    is_leap_year :: proc "contextless" (year: int) -> (leap: bool) {…}

    iso8601_to_components ¶

    iso8601_to_components :: proc(iso_datetime: string) -> (res: datetime.DateTime, utc_offset: int, is_leap: bool, consumed: int) {…}
     

    Parses an ISO 8601 string and returns Time and a UTC offset in minutes. e.g. 1985-04-12T23:20:50.52Z Performs no validation on whether components are valid, e.g. it'll return hour = 25 if that's what it's given

    iso8601_to_time_and_offset ¶

    iso8601_to_time_and_offset :: proc(iso_datetime: string, is_leap: ^bool = nil) -> (res: Time, utc_offset: int, consumed: int) {…}
     

    Parses an ISO 8601 string and returns Time and a UTC offset in minutes. e.g. 1985-04-12T23:20:50.52Z Note: Only 4-digit years are accepted. Optional pointer to boolean is_leap will return true if the moment was a leap second. Leap seconds are smeared into 23:59:59.

    iso8601_to_time_utc ¶

    iso8601_to_time_utc :: proc(iso_datetime: string, is_leap: ^bool = nil) -> (res: Time, consumed: int) {…}
     

    Parses an ISO 8601 string and returns Time in UTC, with any UTC offset applied to it. Only 4-digit years are accepted. Optional pointer to boolean is_leap will return true if the moment was a leap second. Leap seconds are smeared into 23:59:59.

    month ¶

    month :: proc "contextless" (t: Time) -> (month: Month) {…}

    now ¶

    now :: proc "contextless" () -> Time {…}

    read_cycle_counter ¶

    read_cycle_counter :: proc "contextless" () -> u64 {…}

    rfc3339_to_components ¶

    rfc3339_to_components :: proc(rfc_datetime: string) -> (res: datetime.DateTime, utc_offset: int, is_leap: bool, consumed: int) {…}
     

    Parses an RFC 3339 string and returns Time and a UTC offset in minutes. e.g. 1985-04-12T23:20:50.52Z Performs no validation on whether components are valid, e.g. it'll return hour = 25 if that's what it's given

    rfc3339_to_time_and_offset ¶

    rfc3339_to_time_and_offset :: proc(rfc_datetime: string, is_leap: ^bool = nil) -> (res: Time, utc_offset: int, consumed: int) {…}
     

    Parses an RFC 3339 string and returns Time and a UTC offset in minutes. e.g. 1985-04-12T23:20:50.52Z Note: Only 4-digit years are accepted. Optional pointer to boolean is_leap will return true if the moment was a leap second. Leap seconds are smeared into 23:59:59.

    rfc3339_to_time_utc ¶

    rfc3339_to_time_utc :: proc(rfc_datetime: string, is_leap: ^bool = nil) -> (res: Time, consumed: int) {…}
     

    Parses an RFC 3339 string and returns Time in UTC, with any UTC offset applied to it. Only 4-digit years are accepted. Optional pointer to boolean is_leap will return true if the moment was a leap second. Leap seconds are smeared into 23:59:59.

    since ¶

    since :: proc "contextless" (start: Time) -> Duration {…}

    sleep ¶

    sleep :: proc "contextless" (d: Duration) {…}

    stopwatch_duration ¶

    stopwatch_duration :: proc "contextless" (stopwatch: Stopwatch) -> Duration {…}

    stopwatch_reset ¶

    stopwatch_reset :: proc "contextless" (stopwatch: ^Stopwatch) {…}

    stopwatch_start ¶

    stopwatch_start :: proc "contextless" (stopwatch: ^Stopwatch) {…}

    stopwatch_stop ¶

    stopwatch_stop :: proc "contextless" (stopwatch: ^Stopwatch) {…}

    tick_diff ¶

    tick_diff :: proc "contextless" (start, end: Tick) -> Duration {…}

    tick_lap_time ¶

    tick_lap_time :: proc "contextless" (prev: ^Tick) -> Duration {…}

    tick_now ¶

    tick_now :: proc "contextless" () -> Tick {…}

    tick_since ¶

    tick_since :: proc "contextless" (start: Tick) -> Duration {…}

    time_add ¶

    time_add :: proc "contextless" (t: Time, d: Duration) -> Time {…}

    time_to_unix ¶

    time_to_unix :: proc "contextless" (t: Time) -> i64 {…}

    time_to_unix_nano ¶

    time_to_unix_nano :: proc "contextless" (t: Time) -> i64 {…}

    tsc_frequency ¶

    tsc_frequency :: proc "contextless" (fallback_sleep: Duration = 2 * Second) -> (u64, bool) {…}

    unix ¶

    unix :: proc "contextless" (sec: i64, nsec: i64) -> Time {…}

    weekday ¶

    weekday :: proc "contextless" (t: Time) -> (weekday: Weekday) {…}

    year ¶

    year :: proc "contextless" (t: Time) -> (year: int) {…}

    Procedure Groups

    Source Files

    Generation Information

    Generated with odin version dev-2024-07 (vendor "odin") Windows_amd64 @ 2024-07-18 21:09:42.970589900 +0000 UTC