Hi,
Can someone explain why does RollingCalendar::computeTriggeringPeriod
permanently overrides the user's TZ environment variable?
Shouldn't it fetch the users value with getenv, save it temporarily, then set TZ
to GMT and when it's finished restore it?
If this is not a bug, can someone explain what the intent is?
Thanks, Paul.
RollingCalendar::PeriodicityType
RollingCalendar::computeTriggeringPeriod(const String& datePattern)
{
RollingCalendar rollingCalendar(GMT_TIMEZONE);
// set date to 1970-01-01 00:00:00 GMT
int64_t epoch = 0;
if(!datePattern.empty())
{
DateFormat dateFormat(datePattern, GMT_TIMEZONE);
putenv("TZ=GMT");
tzset();
for(int i = TOP_OF_MINUTE; i <= TOP_OF_MONTH; i++)
{
String r0 = dateFormat.format(epoch);
rollingCalendar.setType((PeriodicityType)i);
int64_t next =
rollingCalendar.getNextCheckMillis(epoch);
String r1 = dateFormat.format(next);
//tcout << _T("Type = ") << i << _T(", r0 = ") << r0 <<
_T(", r1 = ");
//tcout << r1 << std::endl;
if (!r0.empty() && !r1.empty() && r0 != r1)
{
return (PeriodicityType)i;
}
}
}
return TOP_OF_TROUBLE; // Deliberately head for trouble...