summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-10-30 14:12:12 -0700
committerOri Bernstein <ori@markovcorp.com>2017-10-30 14:13:32 -0700
commit9a5f51b12293227ab7559c11d8fa5bcf18e49302 (patch)
treedc6809b4498648e4d8553f1642cdf6baa68d24f7
parentd85412f121b5a4bcb8f0e80fd094de363d490117 (diff)
downloadmc-9a5f51b12293227ab7559c11d8fa5bcf18e49302.tar.gz
Use `wday` to get weekday, instead of day of month.
Fixes #148
-rw-r--r--lib/date/fmt.myr4
-rw-r--r--lib/date/test/fmt.myr14
2 files changed, 16 insertions, 2 deletions
diff --git a/lib/date/fmt.myr b/lib/date/fmt.myr
index 323b25a..82f865b 100644
--- a/lib/date/fmt.myr
+++ b/lib/date/fmt.myr
@@ -44,8 +44,8 @@ const datefmt = {sb, fmt, d
if c == '%'
(c, fmt) = std.strstep(fmt)
match c
- | 'a': std.sbfmt(sb, "{}", _names.abbrevday[d.day])
- | 'A': std.sbfmt(sb, "{}", _names.fullday[d.day])
+ | 'a': std.sbfmt(sb, "{}", _names.abbrevday[d.wday])
+ | 'A': std.sbfmt(sb, "{}", _names.fullday[d.wday])
| 'b': std.sbfmt(sb, "{}", _names.abbrevmon[d.mon])
| 'B': std.sbfmt(sb, "{}", _names.fullmon[d.mon])
| 'c': datefmt(sb, "%Y-%m-%d %H:%M:%S %z", d)
diff --git a/lib/date/test/fmt.myr b/lib/date/test/fmt.myr
index d0abba9..45d845a 100644
--- a/lib/date/test/fmt.myr
+++ b/lib/date/test/fmt.myr
@@ -62,6 +62,20 @@ const main = {
d = date.addperiod(d, `date.Day 365)
eq("1972-12-31 00:00:00 +0000", std.bfmt(buf[:], "{D}", d))
+ /* check days */
+ d = date.mkinstant(0, "UTC")
+ eq("Thu", std.bfmt(buf[:], "{f=%a}", d))
+ eq("Thursday", std.bfmt(buf[:], "{f=%A}", d))
+
+ d = date.mkinstant(1409396041 * 1_000_000, "UTC")
+ eq("Sat", std.bfmt(buf[:], "{f=%a}", d))
+ eq("Saturday", std.bfmt(buf[:], "{f=%A}", d))
+
+ d = date.mkinstant(1509396041 * 1_000_000, "UTC")
+ eq("Mon", std.bfmt(buf[:], "{f=%a}", d))
+ eq("Monday", std.bfmt(buf[:], "{f=%A}", d))
+
+
d = date.mkinstant(12*3601*1_000_000, "")
for var i = 0; i < 50; i++
d = date.addperiod(d, `date.Day 1)