// take care of the weekday
ft.tm_mday+=Week.days_till_set(static_cast<Week::WeekDay>(ft.tm_wday));
- // get a time which is _really_ (=undisturbed by DST) at the day we selected
- // 1:59h is a good time for that because it is before DST-change-hours and
- // we currently don't have bigger DST-offsets than +-1:59h today
- // (double-DST 1949 is not relevant because we use unixtime which is 1970+)
- ft.tm_hour=1;
- ft.tm_min=59;
- ft.tm_sec=0;
-
- // one roundtrip to get tm_isdst
- time_t target=mktime(&ft);
- localtime_r(&target,&ft);
-
- // now dstft.tm_isdst is set correctly for the start of the day we selected
-
- // calculate start of the day selected
ft.tm_hour=0;
ft.tm_min=0;
ft.tm_sec=0;
+ // tm_isdst means to use the dst in use at the given time
+ ft.tm_isdst=-1;
// get unixtime of start of the day and add daysec
- target=mktime(&ft)+daysec;
+ time_t target=mktime(&ft)+daysec;
// todays schedule could already been through or now
if (todaycheck && target <= calc_from)
{
// not today but the next matching weekday
- localtime_r(&calc_from,&ft);
ft.tm_mday++;
- return get_next_point(mktime(&ft),daysec,false);
+ ft.tm_isdst=-1;
+ target=get_next_point(mktime(&ft),daysec,false);
}
return target;
// take care of the weekday
ft.tm_mday-=Week.days_since_set(static_cast<Week::WeekDay>(ft.tm_wday));
- // get a time which is _really_ (=undisturbed by DST) at the day we selected
- // 1:59h is a good time for that because it is before DST-change-hours and
- // we currently don't have bigger DST-offsets than +-1:59h today
- // (double-DST 1949 is not relevant because we use unixtime which is 1970+)
- ft.tm_hour=1;
- ft.tm_min=59;
- ft.tm_sec=0;
-
- // one roundtrip to get tm_isdst
- time_t target=mktime(&ft);
- localtime_r(&target,&ft);
-
- // now dstft.tm_isdst is set correctly for the start of the day we selected
-
- // calculate start of the day selected
ft.tm_hour=0;
ft.tm_min=0;
ft.tm_sec=0;
+ // tm_isdst means to use the dst in use at the given time
+ ft.tm_isdst=-1;
// get unixtime of start of the day and add daysec
- target=mktime(&ft)+daysec;
+ time_t target=mktime(&ft)+daysec;
// target later than we are looking for
// target==calc_from is ok (that's why it is called lastnow...)
if (todaycheck && target > calc_from)
{
- // not today but the next matching weekday
- localtime_r(&calc_from,&ft);
+ // not today but the previous matching weekday
ft.tm_mday--;
- return get_previousnow_point(mktime(&ft),daysec,false);
+ ft.tm_isdst=-1;
+ target=get_previousnow_point(mktime(&ft),daysec,false);
}
return target;