pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.c:5659:    if (date->tm_wday < 0)    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; +    #ifdef STRUCT_TM_HAS___TM_GMTOFF    retval += date->__tm_gmtoff;   #elif defined(STRUCT_TM_HAS_GMTOFF)    retval += date->tm_gmtoff; -  + #elif defined(HAVE_EXTERNAL_TIMEZONE) && defined(HAVE_EXTERNAL_ALTZONE) +  if (date->tm_isdst) { +  retval -= altzone; +  } else { +  retval -= timezone; +  }   #else -  normalised_time = retval - mktime(gmtime(&retval)); +  { +  /* NB: The tm from gmtime(3F) will always have tm_isdst == 0, +  * but mktime() is always in the local time zone, and will +  * adjust it and tm_hour if the local time zone is in dst. +  * This causes an error of typically one hour in dst when +  * used without preadjustment. +  */ +  struct tm gmt_tm = *gmtime(&retval); +  gmt_tm.tm_isdst = date->tm_isdst; +  normalised_time += retval - mktime(&gmt_tm); +  }   #endif    retval += normalised_time + tz;    }    return retval;   }      static void unwind_tm()   {    push_static_text("sec");    push_static_text("min");