pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.c:5838:    hour += min / 60;    if ((min %= 60) < 0)    hour--, min += 60;    if ((hour %= 24) < 0)    hour += 24;    normalised_time = ((hour * 60) + min) * 60 + sec;    }       retval = mktime(date);    if (date->tm_wday < 0) { +  if (other_timezone) {    /* NB: This happens for times near {MIN,MAX}_TIME_T. */ -  +  const char *orig_tz = getenv("TZ"); +  char tzbuf[20]; +  ONERROR uwp; +  char *tzsgn = tz < 0 ? "-" : "+"; +  if (tz < 0) tz = -tz; +  sprintf(tzbuf, "TZ=UTC%s%02d:%02d:%02d", +  tzsgn, +  tz/3600, +  (tz/60)%60, +  tz % 60); +  putenv(tzbuf); +  if (!orig_tz) { + #ifdef PUTENV_ALWAYS_REQUIRES_EQUAL +  orig_tz = "TZ="; + #else +  orig_tz = "TZ"; + #endif +  } +  SET_ONERROR(uwp, putenv, orig_tz); +  /* NB: No need to call tzset(); mktime() will call it. */ +  retval = mktime_zone(date, 0, 0); +  CALL_AND_UNSET_ONERROR(uwp); +  return retval; +  }    Pike_error("Time conversion unsuccessful.\n");    }       if(other_timezone)    {    normalised_time -= ((date->tm_hour * 60) + date->tm_min) * 60 + date->tm_sec;    if (normalised_time < -12*60*60)    normalised_time += 24*60*60;    else if (normalised_time > 12*60*60)    normalised_time -= 24*60*60;