diff options
author | John Wiegley <johnw@newartisans.com> | 2008-04-13 03:35:00 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 03:35:00 -0400 |
commit | 42f43b7686038e4cbca16d8d2118b139544e6de3 (patch) | |
tree | 52c5473401c57282242d66b8dd75f4c07bf41d07 /datetime.h | |
parent | c7b4370ff9c8ab5c96f15b1e712e6db6bdab6324 (diff) | |
download | ledger-42f43b7686038e4cbca16d8d2118b139544e6de3.tar.gz ledger-42f43b7686038e4cbca16d8d2118b139544e6de3.tar.bz2 ledger-42f43b7686038e4cbca16d8d2118b139544e6de3.zip |
Check in all changes made so far toward 3.0.
Diffstat (limited to 'datetime.h')
-rw-r--r-- | datetime.h | 21 |
1 files changed, 14 insertions, 7 deletions
@@ -131,6 +131,8 @@ class date_t out << to_string(format); } + void parse(std::istream& in); + friend class datetime_t; friend struct interval_t; }; @@ -158,6 +160,11 @@ inline std::ostream& operator<<(std::ostream& out, const date_t& moment) { return out; } +inline std::istream& operator>>(std::istream& in, date_t& moment) { + moment.parse(in); + return in; +} + class datetime_error : public error { public: datetime_error(const std::string& reason) throw() : error(reason) {} @@ -225,6 +232,8 @@ class datetime_t : public date_t int sec() const { return localtime()->tm_sec; } + + void parse(std::istream& in); }; inline long operator-(const datetime_t& left, const datetime_t& right) { @@ -245,13 +254,11 @@ inline datetime_t operator-(const datetime_t& left, const long seconds) { return temp; } -inline std::ostream& operator<<(std::ostream& out, - const datetime_t& moment) { - char buf[64]; - std::strftime(buf, 63, (date_t::output_format + " %H:%M:%S").c_str(), - moment.localtime()); - out << buf; - return out; +std::ostream& operator<<(std::ostream& out, const datetime_t& moment); + +inline std::istream& operator>>(std::istream& in, datetime_t& moment) { + moment.parse(in); + return in; } struct interval_t |