Always initialize tm_isdst to -1.
This commit is contained in:
parent
46887bad42
commit
5eb8e02451
2 changed files with 22 additions and 11 deletions
27
datetime.cc
27
datetime.cc
|
|
@ -50,10 +50,12 @@ std::time_t interval_t::first(const std::time_t moment) const
|
|||
struct std::tm * desc = std::localtime(&moment);
|
||||
if (years)
|
||||
desc->tm_mon = 0;
|
||||
desc->tm_mday = 1;
|
||||
desc->tm_hour = 0;
|
||||
desc->tm_min = 0;
|
||||
desc->tm_sec = 0;
|
||||
desc->tm_mday = 1;
|
||||
desc->tm_hour = 0;
|
||||
desc->tm_min = 0;
|
||||
desc->tm_sec = 0;
|
||||
desc->tm_isdst = -1;
|
||||
|
||||
quant = std::mktime(desc);
|
||||
|
||||
std::time_t temp;
|
||||
|
|
@ -93,7 +95,7 @@ std::time_t interval_t::increment(const std::time_t moment) const
|
|||
desc->tm_hour = 0;
|
||||
desc->tm_min = 0;
|
||||
desc->tm_sec = 0;
|
||||
desc->tm_isdst = 0;
|
||||
desc->tm_isdst = -1;
|
||||
|
||||
then = std::mktime(desc);
|
||||
}
|
||||
|
|
@ -111,9 +113,10 @@ static void parse_inclusion_specifier(const std::string& word,
|
|||
throw interval_expr_error(std::string("Could not parse date mask: ") +
|
||||
word);
|
||||
|
||||
when.tm_hour = 0;
|
||||
when.tm_min = 0;
|
||||
when.tm_sec = 0;
|
||||
when.tm_hour = 0;
|
||||
when.tm_min = 0;
|
||||
when.tm_sec = 0;
|
||||
when.tm_isdst = -1;
|
||||
|
||||
bool saw_year = true;
|
||||
bool saw_mon = true;
|
||||
|
|
@ -296,9 +299,10 @@ bool parse_date(const char * date_str, std::time_t * result, const int year)
|
|||
if (! parse_date_mask(date_str, &when))
|
||||
return false;
|
||||
|
||||
when.tm_hour = 0;
|
||||
when.tm_min = 0;
|
||||
when.tm_sec = 0;
|
||||
when.tm_hour = 0;
|
||||
when.tm_min = 0;
|
||||
when.tm_sec = 0;
|
||||
when.tm_isdst = -1;
|
||||
|
||||
if (when.tm_year == -1)
|
||||
when.tm_year = ((year == -1) ? now_year : (year - 1900));
|
||||
|
|
@ -348,6 +352,7 @@ bool quick_parse_date(const char * date_str, std::time_t * result)
|
|||
if (base == -1 || year != base_year) {
|
||||
struct std::tm when;
|
||||
std::memset(&when, 0, sizeof(when));
|
||||
when.tm_isdst = -1;
|
||||
|
||||
base_year = year == -1 ? now_year + 1900 : year;
|
||||
when.tm_year = year == -1 ? now_year : year - 1900;
|
||||
|
|
|
|||
|
|
@ -573,6 +573,8 @@ unsigned int textual_parser_t::parse(std::istream& in,
|
|||
last_desc = n ? n : "";
|
||||
|
||||
struct std::tm when;
|
||||
std::memset(&when, 0, sizeof(struct std::tm));
|
||||
when.tm_isdst = -1;
|
||||
if (strptime(date.c_str(), "%Y/%m/%d %H:%M:%S", &when)) {
|
||||
time_in = std::mktime(&when);
|
||||
last_account = account_stack.front()->find_account(p);
|
||||
|
|
@ -593,6 +595,8 @@ unsigned int textual_parser_t::parse(std::istream& in,
|
|||
last_desc = p;
|
||||
|
||||
struct std::tm when;
|
||||
std::memset(&when, 0, sizeof(struct std::tm));
|
||||
when.tm_isdst = -1;
|
||||
if (strptime(date.c_str(), "%Y/%m/%d %H:%M:%S", &when)) {
|
||||
clock_out_from_timelog(std::mktime(&when), journal);
|
||||
count++;
|
||||
|
|
@ -639,6 +643,8 @@ unsigned int textual_parser_t::parse(std::istream& in,
|
|||
std::strcpy(&date_buffer[std::strlen(date_field) + 1], time_field);
|
||||
|
||||
struct std::tm when;
|
||||
std::memset(&when, 0, sizeof(struct std::tm));
|
||||
when.tm_isdst = -1;
|
||||
if (strptime(date_buffer, "%Y/%m/%d %H:%M:%S", &when)) {
|
||||
date = std::mktime(&when);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue