ref: cc9da08bbc40e8b2b4562df28572b58f7e78dbe0
parent: 97bb39c4c2790ea6aa62bbf2779f879fcd9273cf
author: Ori Bernstein <ori@eigenstate.org>
date: Fri Sep 11 07:39:39 EDT 2015
Fix format string issues.
--- a/lib/date/fmt.myr
+++ b/lib/date/fmt.myr
@@ -36,10 +36,10 @@
| '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:], ...?
@@ -46,8 +46,8 @@
| '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 @@
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)
}
--- a/lib/date/parse.myr
+++ b/lib/date/parse.myr
@@ -16,6 +16,7 @@
var d
var err
+ d = [.year = 0]
err = false
s = filldate(&d, f, s, tz, &err)
if err || s.len > 0
--- a/lib/date/test/parse-test.myr
+++ b/lib/date/test/parse-test.myr
@@ -13,7 +13,7 @@
;;
}
-const eq = {expected, actual
+const eq = {actual, expected
if !std.sleq(expected, actual)
std.fatal("expected date {}, got {}\n", expected, actual)
;;