diff options
author | John Wiegley <johnw@newartisans.com> | 2010-12-04 12:46:32 -0500 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2010-12-04 12:51:40 -0500 |
commit | 0be39fce6a383d7ebb92f09649d8d03ac6a1fe9f (patch) | |
tree | af696f9fcfc7664e48c6b2dde6dc5e1a6e8f5df1 /src/times.cc | |
parent | 9bdb384df7b399b2ddb670e8b24fa1279312cd18 (diff) | |
download | fork-ledger-0be39fce6a383d7ebb92f09649d8d03ac6a1fe9f.tar.gz fork-ledger-0be39fce6a383d7ebb92f09649d8d03ac6a1fe9f.tar.bz2 fork-ledger-0be39fce6a383d7ebb92f09649d8d03ac6a1fe9f.zip |
Parse %m/%d/%Y %H:%M:%S as an input date/time
This is to support reading of Timelog files.
Diffstat (limited to 'src/times.cc')
-rw-r--r-- | src/times.cc | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/times.cc b/src/times.cc index b8dcf98f..02e99e53 100644 --- a/src/times.cc +++ b/src/times.cc @@ -185,6 +185,7 @@ namespace { gregorian::date_facet> date_io_t; shared_ptr<datetime_io_t> input_datetime_io; + shared_ptr<datetime_io_t> timelog_datetime_io; shared_ptr<date_io_t> input_date_io; shared_ptr<datetime_io_t> written_datetime_io; shared_ptr<date_io_t> written_date_io; @@ -318,8 +319,12 @@ datetime_t parse_datetime(const char * str) *p = '/'; datetime_t when = input_datetime_io->parse(buf); - if (when.is_not_a_date_time()) - throw_(date_error, _("Invalid date/time: %1") << str); + if (when.is_not_a_date_time()) { + when = timelog_datetime_io->parse(buf); + if (when.is_not_a_date_time()) { + throw_(date_error, _("Invalid date/time: %1") << str); + } + } return when; } @@ -1770,6 +1775,7 @@ void times_initialize() { if (! is_initialized) { input_datetime_io.reset(new datetime_io_t("%Y/%m/%d %H:%M:%S", true)); + timelog_datetime_io.reset(new datetime_io_t("%m/%d/%Y %H:%M:%S", true)); written_datetime_io.reset(new datetime_io_t("%Y/%m/%d %H:%M:%S", false)); written_date_io.reset(new date_io_t("%Y/%m/%d", false)); @@ -1790,6 +1796,7 @@ void times_shutdown() { if (is_initialized) { input_datetime_io.reset(); + timelog_datetime_io.reset(); input_date_io.reset(); written_datetime_io.reset(); written_date_io.reset(); |