summaryrefslogtreecommitdiff
path: root/lib/date
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-04-15 01:07:24 -0700
committerOri Bernstein <ori@eigenstate.org>2015-04-15 01:07:24 -0700
commit8a7f47695be3621942b0b951913814185617fbf0 (patch)
tree1816471c15b76761cea63000ca3d0a9a11a0b6f1 /lib/date
parentbc40668ce5784f97856add94d43e8f3b36e3749a (diff)
downloadmc-8a7f47695be3621942b0b951913814185617fbf0.tar.gz
Update to most recent Myrddin.
Diffstat (limited to 'lib/date')
-rw-r--r--lib/date/bld.proj (renamed from lib/date/bldfile)0
-rw-r--r--lib/date/fmt.myr88
2 files changed, 44 insertions, 44 deletions
diff --git a/lib/date/bldfile b/lib/date/bld.proj
index 8c59015..8c59015 100644
--- a/lib/date/bldfile
+++ b/lib/date/bld.proj
diff --git a/lib/date/fmt.myr b/lib/date/fmt.myr
index 8ed6c7a..f530ca3 100644
--- a/lib/date/fmt.myr
+++ b/lib/date/fmt.myr
@@ -9,76 +9,76 @@ pkg date =
const Datefmt = "%Y-%m-%d %z"
const fmt : (f : byte[:], d : instant -> byte[:])
- const bfmt : (buf : byte[:], f : byte[:], d : instant -> std.size)
+ const bfmt : (buf : byte[:], f : byte[:], d : instant -> byte[:])
;;
const fmt = {f, d
var buf
- var sz
buf = std.slalloc(2048)
- sz = bfmt(buf, f, d)
- -> buf[:sz]
+ -> bfmt(buf, f, d)
}
const bfmt = {buf, f, d
- var c
+ var c, s
var o
o = 0
+ s = ""
while f.len != 0
(c, f) = std.striter(f)
if c == '%'
(c, f) = std.striter(f)
match c
- | 'a': o += std.bfmt(buf[o:], "%s", _names.abbrevday[d.day])
- | 'A': o += std.bfmt(buf[o:], "%s", _names.fullday[d.day])
- | 'b': o += std.bfmt(buf[o:], "%s", _names.abbrevmon[d.mon])
- | 'B': o += std.bfmt(buf[o:], "%s", _names.fullmon[d.mon])
- | 'c': o += bfmt(buf[o:], "%Y-%m-%d", d)
- | 'C': o += std.bfmt(buf[o:], "%02i", d.year % 100)
- | 'd': o += std.bfmt(buf[o:], "%02i", d.day)
- | 'D': o += std.bfmt(buf[o:], "%m/%d/%y (wtf america)", d.mon, d.day, d.year)
- | 'e': o += std.bfmt(buf[o:], "%2i", d.day)
- | 'F': o += std.bfmt(buf[o:], "%y-%m-%d", d.year, d.mon, d.day)
+ | 'a': s = std.bfmt(buf[o:], "%s", _names.abbrevday[d.day])
+ | 'A': s = std.bfmt(buf[o:], "%s", _names.fullday[d.day])
+ | 'b': s = std.bfmt(buf[o:], "%s", _names.abbrevmon[d.mon])
+ | 'B': s = std.bfmt(buf[o:], "%s", _names.fullmon[d.mon])
+ | 'c': s = bfmt(buf[o:], "%Y-%m-%d", d)
+ | 'C': s = std.bfmt(buf[o:], "%02i", d.year % 100)
+ | 'd': s = std.bfmt(buf[o:], "%02i", d.day)
+ | 'D': s = std.bfmt(buf[o:], "%m/%d/%y (wtf america)", d.mon, d.day, d.year)
+ | 'e': s = std.bfmt(buf[o:], "%2i", d.day)
+ | 'F': s = std.bfmt(buf[o:], "%y-%m-%d", d.year, d.mon, d.day)
/*
- | 'G': o += std.bfmt(buf[o:], ...?
+ | 'G': s = std.bfmt(buf[o:], ...?
| 'g':
*/
- | 'h': o += std.bfmt(buf[o:], "%s", _names.abbrevmon[d.mon])
- | 'H': o += std.bfmt(buf[o:], "%02i", d.h)
- | 'I': o += std.bfmt(buf[o:], "%02i", d.h % 12)
- | 'j': o += std.bfmt(buf[o:], "year day... unimplemented.")
- | 'k': o += std.bfmt(buf[o:], "%i", d.h)
- | 'l': o += std.bfmt(buf[o:], "%i", d.h % 12)
- | 'm': o += std.bfmt(buf[o:], "%i", d.mon)
- | 'M': o += std.bfmt(buf[o:], "%i", d.m)
- | 'n': o += std.bfmt(buf[o:], "\n")
- | 'O': o += std.bfmt(buf[o:], "unsupported %O")
- | 'p': o += std.bfmt(buf[o:], "%s", ["AM", "PM"][d.h/12])
- | 'P': o += std.bfmt(buf[o:], "%s", ["am", "pm"][d.h/12])
- | 'r': o += bfmt(buf[o:], "%H:%M:%S %P", d)
- | 'R': o += bfmt(buf[o:], "%H:%M %P", d)
- | 's': o += std.bfmt(buf[o:], "%l", d.actual)
- | 'S': o += std.bfmt(buf[o:], "%i", d.s)
- | 't': o += std.bfmt(buf[o:], "\t")
- | 'u': o += std.bfmt(buf[o:], "%i", d.wday)
- | 'U': o += std.bfmt(buf[o:], "week number... unimplemented.")
- | 'x': o += bfmt(buf[o:], Datefmt, d)
- | 'X': o += bfmt(buf[o:], Timefmt, d)
- | 'y': o += std.bfmt(buf[o:], "%i", d.year % 100)
- | 'Y': o += std.bfmt(buf[o:], "%i", d.year)
- | 'z': o += timezone(buf[o:], d.tzoff)
- | 'Z': o += std.bfmt(buf[o:], "%s", d.tzname)
- | '%': o += std.bfmt(buf[o:], "%%")
+ | 'h': s = std.bfmt(buf[o:], "%s", _names.abbrevmon[d.mon])
+ | 'H': s = std.bfmt(buf[o:], "%02i", d.h)
+ | 'I': s = std.bfmt(buf[o:], "%02i", d.h % 12)
+ | 'j': s = std.bfmt(buf[o:], "year day... unimplemented.")
+ | 'k': s = std.bfmt(buf[o:], "%i", d.h)
+ | 'l': s = std.bfmt(buf[o:], "%i", d.h % 12)
+ | 'm': s = std.bfmt(buf[o:], "%i", d.mon)
+ | 'M': s = std.bfmt(buf[o:], "%i", d.m)
+ | 'n': s = std.bfmt(buf[o:], "\n")
+ | 'O': s = std.bfmt(buf[o:], "unsupported %O")
+ | 'p': s = std.bfmt(buf[o:], "%s", ["AM", "PM"][d.h/12])
+ | 'P': s = std.bfmt(buf[o:], "%s", ["am", "pm"][d.h/12])
+ | 'r': s = bfmt(buf[o:], "%H:%M:%S %P", d)
+ | 'R': s = bfmt(buf[o:], "%H:%M %P", d)
+ | 's': s = std.bfmt(buf[o:], "%l", d.actual)
+ | 'S': s = std.bfmt(buf[o:], "%i", d.s)
+ | 't': s = std.bfmt(buf[o:], "\t")
+ | 'u': s = std.bfmt(buf[o:], "%i", d.wday)
+ | 'U': s = std.bfmt(buf[o:], "week number... unimplemented.")
+ | 'x': s = bfmt(buf[o:], Datefmt, d)
+ | 'X': s = bfmt(buf[o:], Timefmt, d)
+ | 'y': s = std.bfmt(buf[o:], "%i", d.year % 100)
+ | 'Y': s = std.bfmt(buf[o:], "%i", d.year)
+ | 'z': s = timezone(buf[o:], d.tzoff)
+ | 'Z': s = std.bfmt(buf[o:], "%s", d.tzname)
+ | '%': s = std.bfmt(buf[o:], "%%")
| _: std.fatal(1, "unknown format character %c\n", c)
;;
else
- o += std.bfmt(buf[o:], "%c", c)
+ s = std.bfmt(buf[o:], "%c", c)
;;
+ o += s.len
;;
- -> o
+ -> s
}
const timezone = {buf, off