---
mods/+moon.ha | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/mods/+moon.ha b/mods/+moon.ha
index 6a86fe7..3a01132 100644
--- a/mods/+moon.ha
+++ b/mods/+moon.ha
@@ -22,7 +22,7 @@ type hemisphere = enum {Southern, Northern};
fn moon_phase(dt: datetime::datetime, hemisphere: hemisphere) str = {
// Use a known New Moon datetime as reference (January 21, 2023, 20:53 UTC)
const ref_new_moon = datetime::new(time::chrono::UTC, 0, 2023, 1, 21, 20, 53, 0, 0)!;
- const secs = datetime::unitdiff(dt, ref_new_moon, datetime::unit::SECOND): f64;
+ const secs = (chrono::diff(&ref_new_moon, &dt)! / time::SECOND): f64;
const T = 29.53059; // Average synodic period of the Moon
const Tsecs = T * 86400.0;
const phase = math::modf64(secs, Tsecs)/Tsecs;
@@ -39,6 +39,5 @@ export fn mod_moon(pe: *env::env) str = {
case "N" => yield hemisphere::Northern;
case => return strings::dup("+moon.hemisphere:config error");
};
- const now_utc = datetime::in(time::chrono::UTC, datetime::now());
- return strings::dup(moon_phase(now_utc, hemisphere));
+ return strings::dup(moon_phase(datetime::nowutc(), hemisphere));
};
--
2.30.2