commit 54cc11ec53b04ddb8260c338686eca2111eb0992
parent c7af5667d23b1f5776ae7aadc2b8f1b408fb0a0e
Author: Byron Torres <b@torresjrjr.com>
Date: Wed, 29 Dec 2021 22:18:35 +0000
finish hour(), min(), sec(), nsec()
Signed-off-by: Byron Torres <b@torresjrjr.com>
Diffstat:
1 file changed, 24 insertions(+), 4 deletions(-)
diff --git a/datetime/calendar.ha b/datetime/calendar.ha
@@ -199,7 +199,12 @@ export fn isoweek(dt: *datetime) int = {
export fn hour(dt: *datetime) int = {
match (dt.hour) {
case void =>
- abort("TODO");
+ const hmsn = calc_hmsn(dt.time: time::duration);
+ dt.hour = hmsn.0;
+ dt.min = hmsn.1;
+ dt.sec = hmsn.2;
+ dt.nsec = hmsn.3;
+ return dt.hour: int;
case let h: int =>
return h;
};
@@ -209,7 +214,12 @@ export fn hour(dt: *datetime) int = {
export fn min(dt: *datetime) int = {
match (dt.min) {
case void =>
- abort("TODO");
+ const hmsn = calc_hmsn(dt.time: time::duration);
+ dt.hour = hmsn.0;
+ dt.min = hmsn.1;
+ dt.sec = hmsn.2;
+ dt.nsec = hmsn.3;
+ return dt.min: int;
case let m: int =>
return m;
};
@@ -219,7 +229,12 @@ export fn min(dt: *datetime) int = {
export fn sec(dt: *datetime) int = {
match (dt.sec) {
case void =>
- abort("TODO");
+ const hmsn = calc_hmsn(dt.time: time::duration);
+ dt.hour = hmsn.0;
+ dt.min = hmsn.1;
+ dt.sec = hmsn.2;
+ dt.nsec = hmsn.3;
+ return dt.sec: int;
case let s: int =>
return s;
};
@@ -229,7 +244,12 @@ export fn sec(dt: *datetime) int = {
export fn nsec(dt: *datetime) int = {
match (dt.nsec) {
case void =>
- abort("TODO");
+ const hmsn = calc_hmsn(dt.time: time::duration);
+ dt.hour = hmsn.0;
+ dt.min = hmsn.1;
+ dt.sec = hmsn.2;
+ dt.nsec = hmsn.3;
+ return dt.nsec: int;
case let n: int =>
return n;
};