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


Ignore:
Timestamp:
Mar 2, 2007, 9:42:20 AM (18 years ago)
Author:
darin
Message:

Reviewed by Kevin McCullough.

  • kjs/DateMath.h: Marked GregorianDateTime as noncopyable, since it has a non-trivial destructor and not the correspoding copy constructor or assignment operator. Changed the GregorianDateTime constructor to use member initialization syntax. Fixed the destructor to use the array delete operator, since timeZone is an array.
  • kjs/DateMath.cpp: (KJS::daysInYear): Changed to call isLeapYear so the rule is not repeated twice. (KJS::getUTCOffset): Added caching on PLATFORM(DARWIN), since we can rely on the notify_check function and "com.apple.system.timezone" to let us know when the offset has changed.
File:
1 edited

Legend:

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

    r17444 r19943  
    11/*
    22 * Copyright (C) 1999-2000 Harri Porten ([email protected])
    3  * Copyright (C) 2006 Apple Computer
     3 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
    44 *
    55 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
     
    4444#include <time.h>
    4545#include <string.h>
     46#include <wtf/Noncopyable.h>
    4647
    4748namespace KJS {
    4849
    49 // Constants //
    5050const char * const weekdayName[7] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" };
    5151const char * const monthName[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
     
    6060const double msPerDay = 24.0 * 60.0 * 60.0 * 1000.0;
    6161
    62 
    63 // Forward //
    64 struct GregorianDateTime;
    65 
    66 // Exported Functions //
    67 void msToGregorianDateTime(double, bool outputIsUTC, struct GregorianDateTime&);
    68 double gregorianDateTimeToMS(const GregorianDateTime&, double, bool inputIsUTC);
    69 double getUTCOffset();
    70 int equivalentYearForDST(int year);
    71 
    7262// Intentionally overridding the default tm of the system
    7363// Not all OS' have the same members of their tm's
    74 struct GregorianDateTime {
     64struct GregorianDateTime : Noncopyable{
    7565    GregorianDateTime()
     66        : second(0)
     67        , minute(0)
     68        , hour(0)
     69        , weekDay(0)
     70        , monthDay(0)
     71        , yearDay(0)
     72        , month(0)
     73        , year(0)
     74        , isDST(0)
     75        , utcOffset(0)
     76        , timeZone(0)
    7677    {
    77         second = 0;
    78         minute = 0;
    79         hour = 0;
    80         weekDay = 0;
    81         monthDay = 0;
    82         yearDay = 0;
    83         month = 0;
    84         year = 0;
    85         isDST = 0;
    86         utcOffset = 0;
    87         timeZone = NULL;
    8878    }
    8979
    9080    ~GregorianDateTime()
    9181    {
    92         if (timeZone)
    93             delete timeZone;
     82        delete [] timeZone;
    9483    }
    9584   
     
    148137    int month;
    149138    int year;
    150     int  isDST;
     139    int isDST;
    151140    int utcOffset;
    152141    char* timeZone;
    153142};
    154143
     144void msToGregorianDateTime(double, bool outputIsUTC, struct GregorianDateTime&);
     145double gregorianDateTimeToMS(const GregorianDateTime&, double, bool inputIsUTC);
     146double getUTCOffset();
     147int equivalentYearForDST(int year);
     148
    155149}   //namespace KJS
    156150
Note: See TracChangeset for help on using the changeset viewer.