diff options
| author | Julian Hurst <julian.hurst@digdash.com> | 2024-10-17 15:35:32 +0200 |
|---|---|---|
| committer | Julian Hurst <julian.hurst@digdash.com> | 2024-10-17 15:35:34 +0200 |
| commit | f483ec5cc73dde773937f604afcd7705afe66192 (patch) | |
| tree | 79ed514750080c1c7474dfc4e9e7fcd860833d42 /distamp.ha | |
| parent | dd64dfa77837d91c94920515ea943ecc0306ae3f (diff) | |
| download | distamp-f483ec5cc73dde773937f604afcd7705afe66192.tar.gz | |
Parse the absolute date via a virtual
Use a virtual date to parse the user inputted date then fill in the rest
of the date information needed to realize the virtual into a real date.
Diffstat (limited to 'distamp.ha')
| -rw-r--r-- | distamp.ha | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -76,10 +76,13 @@ fn printdistamp(i: i64) void = { }; fn abs(s: str) (i64 | date::error) = { - // for some reason locality needs to be specified twice (hare stdlib bug?) - const stz = strings::concat(s, " Europe/Paris"); - defer free(stz); - let d = date::from_str("%Y-%m-%d %T %L", stz, chrono::tz("Europe/Paris")!)?; + let v = date::newvirtual(); + v.vloc = chrono::LOCAL; + v.zoff = date::zflag::LAP_EARLY | date::zflag::GAP_END; + date::parse(&v, "%Y-%m-%d %T", s)!; + v.nanosecond = 0; + let d = date::realize(v, chrono::LOCAL)!; + //date::format(os::stderr, "%Y-%m-%d %T %L", &d)!; return time::unix(*(&d: *time::instant)); }; |
