diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/textual.cc | 18 | ||||
-rw-r--r-- | src/times.cc | 10 |
2 files changed, 17 insertions, 11 deletions
diff --git a/src/textual.cc b/src/textual.cc index f59496ba..ce945fdf 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -32,6 +32,7 @@ #include "journal.h" #include "account.h" #include "option.h" +#define TIMELOG_SUPPORT 1 #if defined(TIMELOG_SUPPORT) #include "timelog.h" #endif @@ -299,9 +300,11 @@ void instance_t::read_next_directive() case ' ': case '\t': { +#if 0 char * p = skip_ws(line); if (*p) throw parse_error("Line begins with whitespace"); +#endif break; } @@ -384,29 +387,30 @@ void instance_t::read_next_directive() #if defined(TIMELOG_SUPPORT) void instance_t::clock_in_directive(char * line, - bool capitalized) + bool /*capitalized*/) { - string date(line, 2, 19); + string datetime(line, 2, 19); char * p = skip_ws(line + 22); char * n = next_element(p, true); - timelog.clock_in(parse_datetime(date, current_year), + timelog.clock_in(parse_datetime(datetime, current_year), account_stack.front()->find_account(p), n ? n : ""); } void instance_t::clock_out_directive(char * line, - bool capitalized) + bool /*capitalized*/) { - string date(line, 2, 19); + string datetime(line, 2, 19); char * p = skip_ws(line + 22); char * n = next_element(p, true); - timelog.clock_out(parse_datetime(date, current_year), - p ? account_stack.front()->find_account(p) : NULL, n); + timelog.clock_out(parse_datetime(datetime, current_year), + p ? account_stack.front()->find_account(p) : NULL, n ? n : ""); count++; } + #endif // TIMELOG_SUPPORT void instance_t::default_commodity_directive(char * line) diff --git a/src/times.cc b/src/times.cc index 7101d3c6..df760d10 100644 --- a/src/times.cc +++ b/src/times.cc @@ -106,12 +106,14 @@ namespace { } } -datetime_t parse_datetime(const char * str, int current_year) +datetime_t parse_datetime(const char * str, int) { std::tm when; - // jww (2008-08-01): Needs to look for HH:MM:SS as well. - quick_parse_date(str, when, current_year); - return posix_time::ptime_from_tm(when); + std::memset(&when, -1, sizeof(std::tm)); + if (strptime(str, "%Y/%m/%d %H:%M:%S", &when)) + return posix_time::ptime_from_tm(when); + else + return datetime_t(); } date_t parse_date(const char * str, int current_year) |