hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 9d0884fc86c57010975615616ecc572a1f847e1e
parent c5cd986395726cc4bf1ac8020ef3263304813947
Author: Byron Torres <b@torresjrjr.com>
Date:   Sun,  9 Jan 2022 17:36:05 +0000

new datetime::localize() wrapper

Signed-off-by: Byron Torres <b@torresjrjr.com>

Diffstat:
Mdatetime/chronology.ha | 2+-
Mdatetime/timezone.ha | 6++++++
2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/datetime/chronology.ha b/datetime/chronology.ha @@ -208,7 +208,7 @@ export fn min(dt: *datetime) int = { export fn sec(dt: *datetime) int = { // TODO: localize datetimes for all functions here. Use localised date // and time in place of the given datetime's date and time. - const ldt = chrono::localize(to_moment(*dt)); + const ldt = localize(*dt); match (dt.sec) { case void => diff --git a/datetime/timezone.ha b/datetime/timezone.ha @@ -8,3 +8,9 @@ export fn in(loc: chrono::locality, dt: datetime) datetime = { const new_dt = from_moment(new); return new_dt; }; + +// Returns a fictitious datetime which assumes it's own locality is the normal +// locality. Its fields are adjusted by its current zone's offset. +export fn localize(dt: datetime) datetime = { + return from_moment(chrono::localize(to_moment(dt))); +};