diff options
Diffstat (limited to 'distamp.ha')
| -rw-r--r-- | distamp.ha | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -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; |
