| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) | 2  * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) | 
| 3  * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | 3  * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | 
| 4  * Copyright (C) 2009 Google Inc. All rights reserved. | 4  * Copyright (C) 2009 Google Inc. All rights reserved. | 
| 5  * Copyright (C) 2010 Research In Motion Limited. All rights reserved. | 5  * Copyright (C) 2010 Research In Motion Limited. All rights reserved. | 
| 6  * | 6  * | 
| 7  * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 7  * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 
| 8  * | 8  * | 
| 9  * The contents of this file are subject to the Mozilla Public License Version | 9  * The contents of this file are subject to the Mozilla Public License Version | 
| 10  * 1.1 (the "License"); you may not use this file except in compliance with | 10  * 1.1 (the "License"); you may not use this file except in compliance with | 
| (...skipping 29 matching lines...) Expand all  Loading... | 
| 40  * | 40  * | 
| 41  */ | 41  */ | 
| 42 | 42 | 
| 43 #ifndef DateMath_h | 43 #ifndef DateMath_h | 
| 44 #define DateMath_h | 44 #define DateMath_h | 
| 45 | 45 | 
| 46 #include <math.h> | 46 #include <math.h> | 
| 47 #include <stdint.h> | 47 #include <stdint.h> | 
| 48 #include <string.h> | 48 #include <string.h> | 
| 49 #include <time.h> | 49 #include <time.h> | 
| 50 #include <wtf/CurrentTime.h> | 50 #include "wtf/CurrentTime.h" | 
| 51 #include <wtf/Noncopyable.h> | 51 #include "wtf/Noncopyable.h" | 
| 52 #include <wtf/OwnArrayPtr.h> | 52 #include "wtf/OwnArrayPtr.h" | 
| 53 #include <wtf/PassOwnArrayPtr.h> | 53 #include "wtf/PassOwnArrayPtr.h" | 
| 54 #include <wtf/text/WTFString.h> | 54 #include "wtf/text/WTFString.h" | 
| 55 #include <wtf/UnusedParam.h> | 55 #include "wtf/UnusedParam.h" | 
|  | 56 #include "wtf/WTFExport.h" | 
| 56 | 57 | 
| 57 namespace WTF { | 58 namespace WTF { | 
| 58 | 59 | 
| 59 void initializeDates(); | 60 WTF_EXPORT void initializeDates(); | 
| 60 int equivalentYearForDST(int year); | 61 WTF_EXPORT int equivalentYearForDST(int year); | 
| 61 | 62 | 
| 62 // Not really math related, but this is currently the only shared place to put t
     hese. | 63 // Not really math related, but this is currently the only shared place to put t
     hese. | 
| 63 double parseES5DateFromNullTerminatedCharacters(const char* dateString); | 64 WTF_EXPORT double parseES5DateFromNullTerminatedCharacters(const char* dateStrin
     g); | 
| 64 double parseDateFromNullTerminatedCharacters(const char* dateString); | 65 WTF_EXPORT double parseDateFromNullTerminatedCharacters(const char* dateString); | 
| 65 double parseDateFromNullTerminatedCharacters(const char* dateString, bool& haveT
     Z, int& offset); | 66 WTF_EXPORT double parseDateFromNullTerminatedCharacters(const char* dateString, 
     bool& haveTZ, int& offset); | 
| 66 double timeClip(double); | 67 WTF_EXPORT double timeClip(double); | 
| 67 // dayOfWeek: [0, 6] 0 being Monday, day: [1, 31], month: [0, 11], year: ex: 201
     1, hours: [0, 23], minutes: [0, 59], seconds: [0, 59], utcOffset: [-720,720]. | 68 // dayOfWeek: [0, 6] 0 being Monday, day: [1, 31], month: [0, 11], year: ex: 201
     1, hours: [0, 23], minutes: [0, 59], seconds: [0, 59], utcOffset: [-720,720]. | 
| 68 String makeRFC2822DateString(unsigned dayOfWeek, unsigned day, unsigned month, u
     nsigned year, unsigned hours, unsigned minutes, unsigned seconds, int utcOffset)
     ; | 69 WTF_EXPORT String makeRFC2822DateString(unsigned dayOfWeek, unsigned day, unsign
     ed month, unsigned year, unsigned hours, unsigned minutes, unsigned seconds, int
      utcOffset); | 
| 69 | 70 | 
| 70 inline double jsCurrentTime() | 71 inline double jsCurrentTime() | 
| 71 { | 72 { | 
| 72     // JavaScript doesn't recognize fractions of a millisecond. | 73     // JavaScript doesn't recognize fractions of a millisecond. | 
| 73     return floor(WTF::currentTimeMS()); | 74     return floor(WTF::currentTimeMS()); | 
| 74 } | 75 } | 
| 75 | 76 | 
| 76 const char* const weekdayName[7] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "
     Sun" }; | 77 const char* const weekdayName[7] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "
     Sun" }; | 
| 77 const char* const monthName[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "J
     ul", "Aug", "Sep", "Oct", "Nov", "Dec" }; | 78 const char* const monthName[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "J
     ul", "Aug", "Sep", "Oct", "Nov", "Dec" }; | 
| 78 const char* const monthFullName[12] = { "January", "February", "March", "April",
      "May", "June", "July", "August", "September", "October", "November", "December"
      }; | 79 const char* const monthFullName[12] = { "January", "February", "March", "April",
      "May", "June", "July", "August", "September", "October", "November", "December"
      }; | 
| 79 | 80 | 
| 80 const double hoursPerDay = 24.0; | 81 const double hoursPerDay = 24.0; | 
| 81 const double minutesPerHour = 60.0; | 82 const double minutesPerHour = 60.0; | 
| 82 const double secondsPerHour = 60.0 * 60.0; | 83 const double secondsPerHour = 60.0 * 60.0; | 
| 83 const double secondsPerMinute = 60.0; | 84 const double secondsPerMinute = 60.0; | 
| 84 const double msPerSecond = 1000.0; | 85 const double msPerSecond = 1000.0; | 
| 85 const double msPerMinute = 60.0 * 1000.0; | 86 const double msPerMinute = 60.0 * 1000.0; | 
| 86 const double msPerHour = 60.0 * 60.0 * 1000.0; | 87 const double msPerHour = 60.0 * 60.0 * 1000.0; | 
| 87 const double msPerDay = 24.0 * 60.0 * 60.0 * 1000.0; | 88 const double msPerDay = 24.0 * 60.0 * 60.0 * 1000.0; | 
| 88 const double msPerMonth = 2592000000.0; | 89 const double msPerMonth = 2592000000.0; | 
| 89 | 90 | 
| 90 bool isLeapYear(int year); | 91 bool isLeapYear(int year); | 
| 91 | 92 | 
| 92 // Returns the number of days from 1970-01-01 to the specified date. | 93 // Returns the number of days from 1970-01-01 to the specified date. | 
| 93 double dateToDaysFrom1970(int year, int month, int day); | 94 WTF_EXPORT double dateToDaysFrom1970(int year, int month, int day); | 
| 94 int msToYear(double ms); | 95 WTF_EXPORT int msToYear(double ms); | 
| 95 double msToDays(double ms); | 96 WTF_EXPORT double msToDays(double ms); | 
| 96 int msToMinutes(double ms); | 97 WTF_EXPORT int msToMinutes(double ms); | 
| 97 int msToHours(double ms); | 98 WTF_EXPORT int msToHours(double ms); | 
| 98 int dayInYear(int year, int month, int day); | 99 WTF_EXPORT int dayInYear(int year, int month, int day); | 
| 99 int dayInYear(double ms, int year); | 100 WTF_EXPORT int dayInYear(double ms, int year); | 
| 100 int monthFromDayInYear(int dayInYear, bool leapYear); | 101 WTF_EXPORT int monthFromDayInYear(int dayInYear, bool leapYear); | 
| 101 int dayInMonthFromDayInYear(int dayInYear, bool leapYear); | 102 WTF_EXPORT int dayInMonthFromDayInYear(int dayInYear, bool leapYear); | 
| 102 | 103 | 
| 103 // Returns offset milliseconds for UTC and DST. | 104 // Returns offset milliseconds for UTC and DST. | 
| 104 int32_t calculateUTCOffset(); | 105 WTF_EXPORT int32_t calculateUTCOffset(); | 
| 105 double calculateDSTOffset(double ms, double utcOffset); | 106 WTF_EXPORT double calculateDSTOffset(double ms, double utcOffset); | 
| 106 | 107 | 
| 107 } // namespace WTF | 108 } // namespace WTF | 
| 108 | 109 | 
| 109 using WTF::isLeapYear; | 110 using WTF::isLeapYear; | 
| 110 using WTF::dateToDaysFrom1970; | 111 using WTF::dateToDaysFrom1970; | 
| 111 using WTF::dayInMonthFromDayInYear; | 112 using WTF::dayInMonthFromDayInYear; | 
| 112 using WTF::dayInYear; | 113 using WTF::dayInYear; | 
| 113 using WTF::minutesPerHour; | 114 using WTF::minutesPerHour; | 
| 114 using WTF::monthFromDayInYear; | 115 using WTF::monthFromDayInYear; | 
| 115 using WTF::msPerDay; | 116 using WTF::msPerDay; | 
| 116 using WTF::msPerHour; | 117 using WTF::msPerHour; | 
| 117 using WTF::msPerMinute; | 118 using WTF::msPerMinute; | 
| 118 using WTF::msPerSecond; | 119 using WTF::msPerSecond; | 
| 119 using WTF::msToYear; | 120 using WTF::msToYear; | 
| 120 using WTF::msToDays; | 121 using WTF::msToDays; | 
| 121 using WTF::msToMinutes; | 122 using WTF::msToMinutes; | 
| 122 using WTF::msToHours; | 123 using WTF::msToHours; | 
| 123 using WTF::secondsPerMinute; | 124 using WTF::secondsPerMinute; | 
| 124 using WTF::parseDateFromNullTerminatedCharacters; | 125 using WTF::parseDateFromNullTerminatedCharacters; | 
| 125 using WTF::makeRFC2822DateString; | 126 using WTF::makeRFC2822DateString; | 
| 126 using WTF::calculateUTCOffset; | 127 using WTF::calculateUTCOffset; | 
| 127 using WTF::calculateDSTOffset; | 128 using WTF::calculateDSTOffset; | 
| 128 | 129 | 
| 129 #endif // DateMath_h | 130 #endif // DateMath_h | 
| OLD | NEW | 
|---|