From 956ffdf65422b53699957fa31863b55fdc4a8bf5 Mon Sep 17 00:00:00 2001 From: Laytan Laats Date: Fri, 5 May 2023 20:55:59 +0200 Subject: [PATCH 1/2] add time.weekday proc --- core/time/time.odin | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/time/time.odin b/core/time/time.odin index 74c80c8f7..4f4d584ef 100644 --- a/core/time/time.odin +++ b/core/time/time.odin @@ -170,6 +170,12 @@ day :: proc "contextless" (t: Time) -> (day: int) { return } +weekday :: proc "contextless" (t: Time) -> (weekday: Weekday) { + abs := _time_abs(t) + sec := (abs + u64(Weekday.Monday) * SECONDS_PER_DAY) % SECONDS_PER_WEEK + return Weekday(int(sec) / SECONDS_PER_DAY) +} + clock :: proc { clock_from_time, clock_from_duration, clock_from_stopwatch } clock_from_time :: proc "contextless" (t: Time) -> (hour, min, sec: int) { From c47dcbbe2f021a5556fa8d735e7a097a4374bcf4 Mon Sep 17 00:00:00 2001 From: Laytan Laats Date: Sat, 6 May 2023 19:39:39 +0200 Subject: [PATCH 2/2] fix spacing --- core/time/time.odin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/time/time.odin b/core/time/time.odin index 4f4d584ef..6c424a62e 100644 --- a/core/time/time.odin +++ b/core/time/time.odin @@ -172,8 +172,8 @@ day :: proc "contextless" (t: Time) -> (day: int) { weekday :: proc "contextless" (t: Time) -> (weekday: Weekday) { abs := _time_abs(t) - sec := (abs + u64(Weekday.Monday) * SECONDS_PER_DAY) % SECONDS_PER_WEEK - return Weekday(int(sec) / SECONDS_PER_DAY) + sec := (abs + u64(Weekday.Monday) * SECONDS_PER_DAY) % SECONDS_PER_WEEK + return Weekday(int(sec) / SECONDS_PER_DAY) } clock :: proc { clock_from_time, clock_from_duration, clock_from_stopwatch }