diff options
author | Ori Bernstein <ori@eigenstate.org> | 2015-09-11 11:39:39 -0400 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2015-09-11 11:39:39 -0400 |
commit | cc9da08bbc40e8b2b4562df28572b58f7e78dbe0 (patch) | |
tree | 78dce23afbb0ef22e26066fdeea1d6a8cd246d6f /lib/date | |
parent | 97bb39c4c2790ea6aa62bbf2779f879fcd9273cf (diff) | |
download | mc-cc9da08bbc40e8b2b4562df28572b58f7e78dbe0.tar.gz |
Fix format string issues.
Diffstat (limited to 'lib/date')
-rw-r--r-- | lib/date/fmt.myr | 12 | ||||
-rw-r--r-- | lib/date/parse.myr | 1 | ||||
-rw-r--r-- | lib/date/test/parse-test.myr | 2 |
3 files changed, 8 insertions, 7 deletions
diff --git a/lib/date/fmt.myr b/lib/date/fmt.myr index 463f110..a2bcd8d 100644 --- a/lib/date/fmt.myr +++ b/lib/date/fmt.myr @@ -36,18 +36,18 @@ const bfmt = {buf, f, d | 'b': s = std.bfmt(buf[o:], "{}", _names.abbrevmon[d.mon]) | 'B': s = std.bfmt(buf[o:], "{}", _names.fullmon[d.mon]) | 'c': s = bfmt(buf[o:], "%Y-%m-%d", d) - | 'C': s = std.bfmt(buf[o:], "{02}", d.year % 100) - | 'd': s = std.bfmt(buf[o:], "{02}", d.day) + | 'C': s = std.bfmt(buf[o:], "{p=0,w=2}", d.year % 100) + | 'd': s = std.bfmt(buf[o:], "{p=0,w=2}", d.day) | 'D': s = bfmt(buf[o:], "%m/%d/%y (wtf america)", d) - | 'e': s = std.bfmt(buf[o:], "{2}", d.day) + | 'e': s = std.bfmt(buf[o:], "{w=2}", d.day) | 'F': s = bfmt(buf[o:], "%y-%m-%d", d) /* | 'G': s = std.bfmt(buf[o:], ...? | 'g': */ | 'h': s = std.bfmt(buf[o:], "{}", _names.abbrevmon[d.mon]) - | 'H': s = std.bfmt(buf[o:], "{02}", d.h) - | 'I': s = std.bfmt(buf[o:], "{02}", d.h % 12) + | 'H': s = std.bfmt(buf[o:], "{p=0,w=2}", d.h) + | 'I': s = std.bfmt(buf[o:], "{p=0,w=2}", d.h % 12) | 'j': s = std.bfmt(buf[o:], "year day... unimplemented.") | 'k': s = std.bfmt(buf[o:], "{}", d.h) | 'l': s = std.bfmt(buf[o:], "{}", d.h % 12) @@ -93,5 +93,5 @@ const timezone = {buf, off off /= 1_000_000 h = off / 3600 m = off % 3600 - -> std.bfmt(buf, "{}{02}{02}", sep, h, m) + -> std.bfmt(buf, "{}{p=0,w=2}{p=0,w=2}", sep, h, m) } diff --git a/lib/date/parse.myr b/lib/date/parse.myr index 88aff73..dffac5d 100644 --- a/lib/date/parse.myr +++ b/lib/date/parse.myr @@ -16,6 +16,7 @@ const parsefmtz = {f, s, tz var d var err + d = [.year = 0] err = false s = filldate(&d, f, s, tz, &err) if err || s.len > 0 diff --git a/lib/date/test/parse-test.myr b/lib/date/test/parse-test.myr index 1f86924..08de083 100644 --- a/lib/date/test/parse-test.myr +++ b/lib/date/test/parse-test.myr @@ -13,7 +13,7 @@ const main = { ;; } -const eq = {expected, actual +const eq = {actual, expected if !std.sleq(expected, actual) std.fatal("expected date {}, got {}\n", expected, actual) ;; |