aboutsummaryrefslogtreecommitdiff
path: root/distamp.ha
diff options
context:
space:
mode:
authorJulian Hurst <julian.hurst@digdash.com>2024-10-30 18:21:05 +0100
committerJulian Hurst <julian.hurst@digdash.com>2024-10-30 18:21:05 +0100
commitdaf372c98d4a9df43c8270bdf9b414e9820aea90 (patch)
tree24bdc537045cf91d0537740b7411a0723ab749e9 /distamp.ha
parent951a1d7c777902c3d93c0629c5940ac25f827f62 (diff)
downloaddistamp-daf372c98d4a9df43c8270bdf9b414e9820aea90.tar.gz
Add config support for specifying a timezone
Diffstat (limited to 'distamp.ha')
-rw-r--r--distamp.ha16
1 files changed, 11 insertions, 5 deletions
diff --git a/distamp.ha b/distamp.ha
index be2ce02..0b908ed 100644
--- a/distamp.ha
+++ b/distamp.ha
@@ -19,17 +19,22 @@ export fn main() void = {
);
defer getopt::finish(&cmd);
+ const conf = match (loadconfig()) {
+ case let e: conferror =>
+ fmt::fatal(strconferror(e));
+ case let c: config =>
+ yield c;
+ };
+
let days: time::duration = 0;
let weeks: time::duration = 0;
for (let opt .. cmd.opts) {
switch (opt.0) {
case 'a' =>
- match (abs(opt.1)) {
+ match (abs(conf, opt.1)) {
case let i: i64 =>
printdistamp(i);
return;
- case let e: chrono::tzdberror =>
- fmt::fatal(chrono::strerror(e));
case let e: date::parsefail =>
let s = strings::concat(date::strerror(e), "\n", "Date format must be 'year-month-day hour:minute:second'");
defer free(s);
@@ -77,9 +82,10 @@ fn printdistamp(i: i64) void = {
fmt::printfln("<t:{}:R>", i)!;
};
-fn abs(s: str) (i64 | date::error | chrono::tzdberror) = {
+fn abs(conf: config, s: str) (i64 | date::error) = {
let v = date::newvirtual();
- v.vloc = chrono::tz("Europe/Paris")?;
+ v.vloc = conf.tz;
+ //v.vloc = chrono::tz("Europe/Paris")?;
v.zoff = date::zflag::LAP_EARLY | date::zflag::GAP_END;
date::parse(&v, "%Y-%m-%d %T", s)?;
v.nanosecond = 0;