From 3061973f1a40a27ee476ddf2fc9151a5e41c43fb Mon Sep 17 00:00:00 2001 From: JJ Bliss Date: Sun, 26 Apr 2026 19:49:14 -0400 Subject: [PATCH] added datetime device --- uxn/uxn.ha | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/uxn/uxn.ha b/uxn/uxn.ha index 965a559..7e7214f 100644 --- a/uxn/uxn.ha +++ b/uxn/uxn.ha @@ -2,6 +2,8 @@ use fmt; use os; use fs; use io; +use time; +use time::date; use strings; // let console_vector: u16 = 0; @@ -84,6 +86,44 @@ fn emu_dei(port: u8, state: *uxn) u8 = { return state.ptr[0]; case 0x05 => return state.ptr[1]; + case 0xc0 => + const date = time::date::localnow(); + const year = time::date::year(&date); + return ((year) >> 8): u8; + case 0xc1 => + const date = time::date::localnow(); + const year = time::date::year(&date); + return year: u8; + case 0xc2 => + const date = time::date::localnow(); + return time::date::month(&date): u8 - 1; + case 0xc3 => + const date = time::date::localnow(); + return time::date::day(&date): u8; + case 0xc4 => + const date = time::date::localnow(); + return time::date::hour(&date): u8; + case 0xc5 => + const date = time::date::localnow(); + return time::date::minute(&date): u8; + case 0xc6 => + const date = time::date::localnow(); + return time::date::second(&date): u8; + case 0xc7 => + const date = time::date::localnow(); + return time::date::weekday(&date): u8; + case 0xc8 => + const date = time::date::localnow(); + const day = time::date::yearday(&date) - 1; + return ((day) >> 8): u8; + case 0xc9 => + const date = time::date::localnow(); + const day = time::date::yearday(&date) - 1; + return day: u8; + case 0xca => + const date = time::date::localnow(); + const zone = time::date::zone(&date); + return if(zone.dst) {yield 1;} else {yield 0;}; //TODO this isn't tested case => return state.dev[port]; // fmt::printfln("Read {:x} from port {:x}", val, port)!;