aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Hurst <ark@mansus.space>2025-10-10 19:36:27 +0200
committerJulian Hurst <ark@mansus.space>2025-10-10 19:36:27 +0200
commitb230946668e575f6290cf3f29afce63f8734402a (patch)
tree7b61920c9e7f20d09e84b7f7d4e9a8a2c2c9e4bf
parent682c89e3f623034f4afda70c1e748198c03c7ea3 (diff)
downloaddistamp-hareversionbump.tar.gz
Changes for new hare version (0.25.2)hareversionbump
-rw-r--r--config.ha15
-rw-r--r--distamp.ha24
2 files changed, 25 insertions, 14 deletions
diff --git a/config.ha b/config.ha
index d3ee234..ba454f0 100644
--- a/config.ha
+++ b/config.ha
@@ -1,3 +1,4 @@
+use time::date;
use fmt;
use dirs;
use format::ini;
@@ -10,12 +11,12 @@ use errors;
use strings;
type config = struct {
- tz: chrono::locality,
+ tz: date::locality,
};
type noexist = !str;
-type conferror = !(path::error | noexist | fs::error | chrono::tzdberror);
+type conferror = !(path::error | noexist | fs::error | date::tzdberror | nomem);
fn loadconfig() (config | conferror) = {
const confdir = dirs::config("distamp");
@@ -25,7 +26,7 @@ fn loadconfig() (config | conferror) = {
case let e: errors::noentry =>
fmt::errorln("warn: No config file found")!;
return config {
- tz = chrono::LOCAL,
+ tz = date::LOCAL,
};
case let e: fs::error =>
return e;
@@ -35,12 +36,12 @@ fn loadconfig() (config | conferror) = {
defer io::close(f)!;
const sc = ini::scan(f);
- let tz: chrono::locality = chrono::LOCAL;
+ let tz: date::locality= date::LOCAL;
for (const e => ini::next(&sc)!) {
const key = strings::trim(e.1);
const val = strings::trim(e.2);
if (key == "tz") {
- tz = chrono::tz(val)?;
+ tz = date::tzdb(val)?;
};
};
return config {
@@ -54,7 +55,7 @@ fn strconferror(e: conferror) str = {
return path::strerror(e);
case let e: fs::error =>
return fs::strerror(e);
- case let e: chrono::tzdberror =>
- return chrono::strerror(e);
+ case let e: date::tzdberror=>
+ return date::strerror(e);
};
};
diff --git a/distamp.ha b/distamp.ha
index 7e44522..ada63b1 100644
--- a/distamp.ha
+++ b/distamp.ha
@@ -46,12 +46,22 @@ export fn main() void = {
printdistamp(i);
return;
case let e: date::parsefail =>
- let s = strings::concat(date::strerror(e), "\n", "Date format must be 'year-month-day hour:minute:second'");
+ let s = strings::concat(date::strerror(e), "\n", "Date format must be 'year-month-day hour:minute:second'")!;
defer free(s);
fmt::errorln(s)!;
return;
- case let e: date::error =>
+ case let e: date::insufficient =>
fmt::fatal(date::strerror(e));
+ case let e: date::invalid =>
+ fmt::fatal(date::strerror(e));
+ case let e: date::zfunresolved =>
+ fmt::fatal(date::strerror(e));
+ case let e: io::error =>
+ fmt::fatal(io::strerror(e));
+ case let e: utf8::invalid =>
+ fmt::fatal(utf8::strerror(e));
+ case nomem =>
+ fmt::fatal("No memory left");
};
case 'w' =>
weeks = match (toweeks(opt.1)) {
@@ -93,14 +103,14 @@ export fn main() void = {
li = time::add(li, days);
li = time::add(li, weeks);
- printdistamp(time::unix(li));
+ printdistamp(li.sec);
};
fn printdistamp(i: i64) void = {
fmt::printfln("<t:{}:R>", i)!;
};
-fn abs(conf: config, s: str) (i64 | date::error | io::error | utf8::invalid) = {
+fn abs(conf: config, s: str) (i64 | date::invalid | date::insufficient | date::zfunresolved | date::parsefail | io::error | utf8::invalid | nomem) = {
let v = date::newvirtual();
v.vloc = conf.tz;
v.zoff = date::zflag::LAP_EARLY | date::zflag::GAP_END;
@@ -116,16 +126,16 @@ fn abs(conf: config, s: str) (i64 | date::error | io::error | utf8::invalid) = {
void;
};
v.nanosecond = 0;
- let d = date::realize(v, chrono::LOCAL)?;
+ let d = date::realize(v, date::LOCAL)?;
//date::format(os::stderr, "%Y-%m-%d %T %L", &d)!;
- return time::unix(*(&d: *time::instant));
+ return (&d: *time::instant).sec;
};
fn parsemainargs(args: []str) (time::instant | parseerror) = {
return if (len(args) == 1) {
let timestr = args[0];
let i = time::now(time::clock::REALTIME);
- let spl = strings::split(timestr, ":");
+ let spl = strings::split(timestr, ":")!;
defer free(spl);
yield if (len(spl) > 2) {