shithub: mc

Download patch

ref: f2854813a1a6c4603480af0a23d62d60fff770a2
parent: f7228d204a9cbe40f7b6286ba8987ef65691bfbd
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Sep 21 18:39:01 EDT 2015

Test for leap year transitions.

--- a/lib/date/date.myr
+++ b/lib/date/date.myr
@@ -203,3 +203,4 @@
 	tm += (3600*h + 60*m + s)*1_000_000 + us
 	-> tm
 }
+
--- a/lib/date/test/fmt.myr
+++ b/lib/date/test/fmt.myr
@@ -54,6 +54,14 @@
 	d = date.subperiod(d, `date.Year 1)
 	eq("1969-1-01 00:00:00 +0000", std.bfmt(buf[:], "{D}", d))
 
+	d = date.addperiod(d, `date.Day 365)
+	eq("1970-1-01 00:00:00 +0000", std.bfmt(buf[:], "{D}", d))
+
+	d = date.addperiod(d, `date.Year 2)
+	eq("1972-1-01 00:00:00 +0000", std.bfmt(buf[:], "{D}", d))
+	d = date.addperiod(d, `date.Day 365)
+	eq("1972-12-31 00:00:00 +0000", std.bfmt(buf[:], "{D}", d))
+
 	d = date.mkinstant(12*3601*1_000_000, "")
 	for var i = 0; i < 50; i++
 		d = date.addperiod(d, `date.Day 1)