ref: 9a5f51b12293227ab7559c11d8fa5bcf18e49302
parent: d85412f121b5a4bcb8f0e80fd094de363d490117
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Oct 30 10:12:12 EDT 2017
Use `wday` to get weekday, instead of day of month. Fixes #148
--- a/lib/date/fmt.myr
+++ b/lib/date/fmt.myr
@@ -44,8 +44,8 @@
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)
--- a/lib/date/test/fmt.myr
+++ b/lib/date/test/fmt.myr
@@ -62,6 +62,20 @@
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)