diff options
author | Ori Bernstein <ori@eigenstate.org> | 2015-01-03 18:16:40 -0800 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2015-01-03 18:16:40 -0800 |
commit | b10b3137d2423629ee2641bf178196e243697c20 (patch) | |
tree | b20468ac42b467fc64be7be32965e134182bbeb4 /lib/date | |
parent | 3dd66ec7cb4541a8909e2e4fc6da8d733f1ae0db (diff) | |
download | mc-b10b3137d2423629ee2641bf178196e243697c20.tar.gz |
Fix namespace conflicts.
date.foo doesn't work in namespace 'date'.
Diffstat (limited to 'lib/date')
-rw-r--r-- | lib/date/date.myr | 30 | ||||
-rw-r--r-- | lib/date/fmt.myr | 1 | ||||
-rw-r--r-- | lib/date/parse.myr | 21 |
3 files changed, 27 insertions, 25 deletions
diff --git a/lib/date/date.myr b/lib/date/date.myr index 5c3171b..dcc5149 100644 --- a/lib/date/date.myr +++ b/lib/date/date.myr @@ -45,16 +45,16 @@ const tozone = {d, tz const mkinstant = {tm, tz var j, y, m, d var t, e - var date + var inst var off - date.actual = tm + inst.actual = tm /* time zones */ - std.assert(tz.len <= date._tzbuf.len, "time zone name too long\n") + std.assert(tz.len <= inst._tzbuf.len, "time zone name too long\n") off =_zoneinfo.findtzoff(tz, tm) - date.tzoff = off - std.slcp(date._tzbuf[:tz.len], tz) - date.tzname = date._tzbuf[:tz.len] + inst.tzoff = off + std.slcp(inst._tzbuf[:tz.len], tz) + inst.tzname = inst._tzbuf[:tz.len] tm += off castto(std.time) /* break up time */ @@ -63,16 +63,16 @@ const mkinstant = {tm, tz /* microseconds, seconds, minutes, hours */ - date.us = (t % 1_000_000) castto(int) + inst.us = (t % 1_000_000) castto(int) t /= 1_000_000 - date.s = (t % 60) castto(int) + inst.s = (t % 60) castto(int) t /= 60 - date.m = (t % 60) castto(int) + inst.m = (t % 60) castto(int) t /= 60 - date.h = t castto(int) + inst.h = t castto(int) /* weekday */ - date.wday = ((e + 4) % 7) castto(int) /* the world started on Thursday */ + inst.wday = ((e + 4) % 7) castto(int) /* the world started on Thursday */ /* split up year, month, day. @@ -100,10 +100,10 @@ const mkinstant = {tm, tz m -= 9 y++ ;; - date.year = y castto(int) - date.mon = m castto(int) - date.day = (d + 1) castto(int) - -> date + inst.year = y castto(int) + inst.mon = m castto(int) + inst.day = (d + 1) castto(int) + -> inst } const localoff = {tm diff --git a/lib/date/fmt.myr b/lib/date/fmt.myr index 21606d7..8ed6c7a 100644 --- a/lib/date/fmt.myr +++ b/lib/date/fmt.myr @@ -72,6 +72,7 @@ const bfmt = {buf, f, d | 'z': o += timezone(buf[o:], d.tzoff) | 'Z': o += std.bfmt(buf[o:], "%s", d.tzname) | '%': o += std.bfmt(buf[o:], "%%") + | _: std.fatal(1, "unknown format character %c\n", c) ;; else o += std.bfmt(buf[o:], "%c", c) diff --git a/lib/date/parse.myr b/lib/date/parse.myr index 82429a5..2faa00b 100644 --- a/lib/date/parse.myr +++ b/lib/date/parse.myr @@ -114,6 +114,7 @@ const filldate = {d, f, s, tz, err -> byte[:] | 'Z': o += std.bfmt(buf[o:], "%s", d.tzname) */ | '%': s = matchstr(s, "%", err) + | _: std.fatal(1, "unknown format character %c\n", fc) ;; else (sc, s) = std.striter(s) @@ -199,17 +200,17 @@ const matchampm = {d, s, err ;; } -const time = {date +const time = {inst var t var c, y, ya, m, u t = 0 - if date.mon > 2 - m = (date.mon - 3) castto(std.time) + if inst.mon > 2 + m = (inst.mon - 3) castto(std.time) else - m = (date.mon + 9) castto(std.time) - y = (date.year - 1) castto(std.time) + m = (inst.mon + 9) castto(std.time) + y = (inst.year - 1) castto(std.time) ;; c = y / 100 @@ -217,13 +218,13 @@ const time = {date u = (146097 * c) / 4 + \ (1461 * ya) / 4 + \ (153 * m + 2) / 5 + \ - (date.day castto(std.time)) + \ + (inst.day castto(std.time)) + \ UnixJulianDiff t += (u * 24*60*60*1_000_000) - t += (date.h castto(std.time)) * 60*60*1_000_000 - t += (date.m castto(std.time)) * 60*1_000_000 - t += (date.s castto(std.time)) * 1_000_000 - t += date.us castto(std.time) + t += (inst.h castto(std.time)) * 60*60*1_000_000 + t += (inst.m castto(std.time)) * 60*1_000_000 + t += (inst.s castto(std.time)) * 1_000_000 + t += inst.us castto(std.time) -> t } |