Changeset 17031 in webkit for trunk/JavaScriptCore/kjs/DateMath.h


Ignore:
Timestamp:
Oct 13, 2006, 10:31:11 AM (19 years ago)
Author:
kmccullo
Message:

Reviewed by Adam, Geoff, Darin.

Fixed displaying the UTC offset and time zone string, as well as renamed the GregorianDateTime structure and clean up.

  • ChangeLog:
  • kjs/DateMath.cpp: (KJS::getUTCOffset): (KJS::getDSTOffsetSimple): (KJS::gregorianDateTimeToMS): (KJS::msToGregorianDateTime):
  • kjs/DateMath.h: (KJS::GregorianDateTime::GregorianDateTime): (KJS::GregorianDateTime::~GregorianDateTime): (KJS::GregorianDateTime::toTM):
  • kjs/date_object.cpp: (KJS::gmtoffset): (KJS::formatDate): (KJS::formatDateUTCVariant): (KJS::formatTime): (KJS::fillStructuresUsingTimeArgs): (KJS::fillStructuresUsingDateArgs): (KJS::DateInstance::getTime): (KJS::DateInstance::getUTCTime): (KJS::DateProtoFunc::callAsFunction): (KJS::DateObjectImp::construct): (KJS::DateObjectImp::callAsFunction): (KJS::DateObjectFuncImp::callAsFunction): (KJS::parseDate):
  • kjs/date_object.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/DateMath.h

    r17010 r17031  
    4848// Intentionally overridding the default tm of the system
    4949// Not all OS' have the same members of their tm's
    50 struct tm {
    51     int tm_sec;
    52     int tm_min;
    53     int tm_hour;
    54     int tm_wday;
    55     int tm_mday;
    56     int tm_yday;
    57     int tm_mon;
    58     int tm_year;
    59     int tm_isdst;
    60     long tm_gmtoff;
    61     char* tm_zone;
     50struct GregorianDateTime {
     51    GregorianDateTime()
     52    {
     53        second = 0;
     54        minute = 0;
     55        hour = 0;
     56        weekDay = 0;
     57        monthDay = 0;
     58        yearDay = 0;
     59        month = 0;
     60        year = 0;
     61        isDST = 0;
     62        utcOffset = 0;
     63        timeZone = NULL;
     64    }
     65
     66    ~GregorianDateTime()
     67    {
     68        if (timeZone)
     69            delete timeZone;
     70    }
     71   
     72    GregorianDateTime(const tm& inTm)
     73        : second(inTm.tm_sec)
     74        , minute(inTm.tm_min)
     75        , hour(inTm.tm_hour)
     76        , weekDay(inTm.tm_wday)
     77        , monthDay(inTm.tm_mday)
     78        , yearDay(inTm.tm_yday)
     79        , month(inTm.tm_mon)
     80        , year(inTm.tm_year)
     81        , isDST(inTm.tm_isdst)
     82    {
     83#if !PLATFORM(WIN_OS)
     84        utcOffset = static_cast<int>(inTm.tm_gmtoff);
     85
     86        int inZoneSize = strlen(inTm.tm_zone) + 1;
     87        timeZone = new char[inZoneSize];
     88        strncpy(timeZone, inTm.tm_zone, inZoneSize);
     89#else
     90        utcOffset = 0;
     91        timeZone = NULL;
     92#endif
     93    }
     94
     95    tm toTM() const
     96    {
     97        tm ret;
     98        memset(&ret, 0, sizeof(ret));
     99
     100        ret.tm_sec   =  second;
     101        ret.tm_min   =  minute;
     102        ret.tm_hour  =  hour;
     103        ret.tm_wday  =  weekDay;
     104        ret.tm_mday  =  monthDay;
     105        ret.tm_yday  =  yearDay;
     106        ret.tm_mon   =  month;
     107        ret.tm_year  =  year;
     108        ret.tm_isdst =  isDST;
     109
     110#if !PLATFORM(WIN_OS)
     111        ret.tm_gmtoff = static_cast<long>(utcOffset);
     112        ret.tm_zone = timeZone;
     113#endif
     114
     115        return ret;
     116    }
     117
     118    int second;
     119    int minute;
     120    int hour;
     121    int weekDay;
     122    int monthDay;
     123    int yearDay;
     124    int month;
     125    int year;
     126    int  isDST;
     127    int utcOffset;
     128    char* timeZone;
    62129};
    63130
     
    76143
    77144// Exported Functions //
    78 void msToTM(double, bool outputIsUTC, struct tm& );
    79 double dateToMS(const tm&, double, bool inputIsUTC);
     145void msToGregorianDateTime(double, bool outputIsUTC, struct GregorianDateTime&);
     146double gregorianDateTimeToMS(const GregorianDateTime&, double, bool inputIsUTC);
    80147double getUTCOffset();
    81 
    82 tm tmToKJStm(const struct ::tm&);
    83 ::tm KJStmToTm(const struct tm&);
    84148
    85149}   //namespace KJS
Note: See TracChangeset for help on using the changeset viewer.