Ignore:
Timestamp:
Nov 29, 2005, 2:33:22 AM (20 years ago)
Author:
eseidel
Message:

Bug #: 5514
Submitted by: mitz
Reviewed by: ggaren

Date conversion to local time gets the DST flag wrong sometimes
http://bugzilla.opendarwin.org/show_bug.cgi?id=5514

  • kjs/date_object.cpp: (KJS::isTime_tSigned): (KJS::DateProtoFuncImp::callAsFunction):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/date_object.cpp

    r10932 r11331  
    470470}
    471471
     472static bool isTime_tSigned()
     473{
     474    time_t minusOne = (time_t)(-1);
     475    return minusOne < 0;
     476}
     477
    472478ValueImp *DateProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
    473479{
     
    523529  // check whether time value is outside time_t's usual range
    524530  // make the necessary transformations if necessary
     531  static bool time_tIsSigned = isTime_tSigned();
     532  static double time_tMin = (time_tIsSigned ? - (double)(1ULL << (8 * sizeof(time_t) - 1)) : 0);
     533  static double time_tMax = (time_tIsSigned ? (1ULL << 8 * sizeof(time_t) - 1) - 1 : 2 * (double)(1ULL << 8 * sizeof(time_t) - 1) - 1);
    525534  int realYearOffset = 0;
    526535  double milliOffset = 0.0;
    527536  double secs = floor(milli / msPerSecond);
    528537
    529   if (milli < 0 || milli >= timeFromYear(2038)) {
     538  if (secs < time_tMin || secs > time_tMax) {
    530539    // ### ugly and probably not very precise
    531540    int realYear = yearFromTime(milli);
Note: See TracChangeset for help on using the changeset viewer.