diff options
author | John Wiegley <johnw@newartisans.com> | 2008-07-29 21:38:20 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-07-29 21:44:21 -0400 |
commit | 1bb29cdbb7fa63d2fd5312e3fc81bcc489aaab5d (patch) | |
tree | d5c7e3897763a8a9d4b05c438d1c1bcb8020ee04 /times.h | |
parent | 42e1d725aa9deb41396ba4c73c8499c7c3798508 (diff) | |
download | fork-ledger-1bb29cdbb7fa63d2fd5312e3fc81bcc489aaab5d.tar.gz fork-ledger-1bb29cdbb7fa63d2fd5312e3fc81bcc489aaab5d.tar.bz2 fork-ledger-1bb29cdbb7fa63d2fd5312e3fc81bcc489aaab5d.zip |
The register report has begun printing real data, although not all the pieces
are in place yet and the formatting is still off.
Diffstat (limited to 'times.h')
-rw-r--r-- | times.h | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -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; |