From 1bb29cdbb7fa63d2fd5312e3fc81bcc489aaab5d Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 29 Jul 2008 21:38:20 -0400 Subject: The register report has begun printing real data, although not all the pieces are in place yet and the formatting is still off. --- times.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'times.h') diff --git a/times.h b/times.h index 65513ca8..1edaa2b2 100644 --- a/times.h +++ b/times.h @@ -152,8 +152,22 @@ inline datetime_t parse_datetime(const string& str) { return parse_datetime(str.c_str()); } +inline std::time_t to_time_t(const ptime& t) +{ + if( t == posix_time::neg_infin ) + return 0; + else if( t == posix_time::pos_infin ) + return LONG_MAX; + ptime start(date(1970,1,1)); + return (t-start).total_seconds(); +} + inline string format_datetime(const datetime_t& when) { - return ""; // jww (2008-07-19): NYI + char buf[64]; + time_t moment = to_time_t(when); + // jww (2008-07-29): Need to make the output format configurable + std::strftime(buf, 63, "%Y/%m/%d", std::localtime(&moment)); + return buf; } extern const ptime time_now; -- cgit v1.2.3