shithub: mc

Download patch

ref: f9135fb90f213d2c0167a5855f18ac2fd500ccdc
parent: d6883b7f794b12741cb0246142daa5355e9ea279
author: Ori Bernstein <ori@eigenstate.org>
date: Thu Aug 28 18:28:28 EDT 2014

Add support for default formats.

--- a/lib/date/date.myr
+++ b/lib/date/date.myr
@@ -8,7 +8,7 @@
 	const parsefmt	: (fmt : byte[:], d : byte[:]	-> date)
 	const parsez	: (d : byte[:], tz : byte[:]	-> date)
 	const fmt	: (d : date	-> byte[:])
-	const bfmt	: (d : date, buf : byte[:]	-> byte[:])
+	const bfmt	: (buf : byte[:], d : date	-> std.size)
 
 	/* useful constructors */
 	const mkdate	: (tm : std.time, tz : diff -> date)
@@ -26,11 +26,18 @@
 const Days400y	= 365*400 + 4*25 - 3
 const Days4y	= 365*4 + 1
 
+const fmt = {d
+	-> std.fmt("%04i-%02i-%02i %i:%i:%i", d.year, d.mon, d.day, d.h, d.m, d.s)
+}
+
+const bfmt = {buf, d
+	-> std.bfmt(buf, "%04i-%02i-%02i %i:%i:%i", d.year, d.mon, d.day, d.h, d.m, d.s)
+}
+
 const now = {tz : byte[:]
 	var tm
 
 	tm = std.now()
-	std.put("%l\n", _zoneinfo.findtzoff(tz, tm))
 	-> mkdate(tm, _zoneinfo.findtzoff(tz, tm))
 }