Added several more date/time fixes from Nathan Jones. Fixes #49.

This commit is contained in:
John Wiegley 2008-07-17 06:19:40 -04:00
parent f482d120fd
commit 95f323f137
2 changed files with 6 additions and 3 deletions

View file

@ -16,10 +16,13 @@ std::string date_t::input_format;
std::string date_t::output_format = "%Y/%m/%d"; std::string date_t::output_format = "%Y/%m/%d";
const char * date_t::formats[] = { const char * date_t::formats[] = {
"%y/%m/%d",
"%Y/%m/%d", "%Y/%m/%d",
"%m/%d", "%m/%d",
"%y.%m.%d",
"%Y.%m.%d", "%Y.%m.%d",
"%m.%d", "%m.%d",
"%y-%m-%d",
"%Y-%m-%d", "%Y-%m-%d",
"%m-%d", "%m-%d",
"%a", "%a",
@ -349,7 +352,7 @@ namespace {
when.tm_sec = 0; when.tm_sec = 0;
if (when.tm_year == -1) if (when.tm_year == -1)
when.tm_year = ((year == -1) ? date_t::current_year : (year - 1900)); when.tm_year = ((year == -1) ? date_t::current_year : year) - 1900;
if (when.tm_mon == -1) if (when.tm_mon == -1)
when.tm_mon = 0; when.tm_mon = 0;
@ -364,6 +367,6 @@ namespace {
bool quick_parse_date(const char * date_str, std::time_t * result) bool quick_parse_date(const char * date_str, std::time_t * result)
{ {
return parse_date(date_str, result, date_t::current_year + 1900); return parse_date(date_str, result, date_t::current_year);
} }
} }

View file

@ -712,7 +712,7 @@ unsigned int textual_parser_t::parse(std::istream& in,
} }
case 'Y': // set the current year case 'Y': // set the current year
date_t::current_year = std::atoi(skip_ws(line + 1)) - 1900; date_t::current_year = std::atoi(skip_ws(line + 1));
break; break;
#ifdef TIMELOG_SUPPORT #ifdef TIMELOG_SUPPORT