15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)/* 25c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (C) 2009 Google Inc. All rights reserved. 35c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 45c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without 55c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * modification, are permitted provided that the following conditions are 65c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * met: 75c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 85c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * * Redistributions of source code must retain the above copyright 95c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * notice, this list of conditions and the following disclaimer. 105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * * Redistributions in binary form must reproduce the above 115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * copyright notice, this list of conditions and the following disclaimer 125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * in the documentation and/or other materials provided with the 135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * distribution. 145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * * Neither the name of Google Inc. nor the names of its 155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * contributors may be used to endorse or promote products derived from 165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * this software without specific prior written permission. 175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) */ 305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#ifndef DateComponents_h 325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define DateComponents_h 335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include <limits> 351e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)#include "platform/PlatformExport.h" 367757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch#include "wtf/Forward.h" 377757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch#include "wtf/unicode/Unicode.h" 385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 39c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink { 405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// A DateComponents instance represents one of the following date and time combinations: 425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// * Month type: year-month 435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// * Date type: year-month-day 445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// * Week type: year-week 455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// * Time type: hour-minute-second-millisecond 465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// * DateTime or DateTimeLocal type: year-month-day hour-minute-second-millisecond 471e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)class PLATFORM_EXPORT DateComponents { 485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)public: 495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) DateComponents() 505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) : m_millisecond(0) 515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) , m_second(0) 525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) , m_minute(0) 535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) , m_hour(0) 545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) , m_monthDay(0) 555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) , m_month(0) 565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) , m_year(0) 575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) , m_week(0) 585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) , m_type(Invalid) 595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) { 605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) enum Type { 635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Invalid, 645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Date, 655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) DateTime, 665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) DateTimeLocal, 675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Month, 685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Time, 695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Week, 705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) }; 715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) int millisecond() const { return m_millisecond; } 735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) int second() const { return m_second; } 745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) int minute() const { return m_minute; } 755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) int hour() const { return m_hour; } 765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) int monthDay() const { return m_monthDay; } 77d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) int weekDay() const; 785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) int month() const { return m_month; } 795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) int fullYear() const { return m_year; } 805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) int week() const { return m_week; } 815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Type type() const { return m_type; } 825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) enum SecondFormat { 845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) None, // Suppress the second part and the millisecond part if they are 0. 855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Second, // Always show the second part, and suppress the millisecond part if it is 0. 865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Millisecond // Always show the second part and the millisecond part. 875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) }; 885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Returns an ISO 8601 representation for this instance. 905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // The format argument is valid for DateTime, DateTimeLocal, and Time types. 915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) String toString(SecondFormat format = None) const; 925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // parse*() and setMillisecondsSince*() functions are initializers for an 945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // DateComponents instance. If these functions return false, the instance 955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // might be invalid. 965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // The following six functions parse the input 'src' whose length is 985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // 'length', and updates some fields of this instance. The parsing starts at 995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // src[start] and examines characters before src[length]. 1005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // 'src' must be non-null. The 'src' string doesn't need to be 1015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // null-terminated. 1025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // The functions return true if the parsing succeeds, and set 'end' to the 1035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // next index after the last consumed. Extra leading characters cause parse 1045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // failures, and the trailing extra characters don't cause parse failures. 1055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Sets year and month. 107591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch bool parseMonth(const String&, unsigned start, unsigned& end); 1085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Sets year, month and monthDay. 109591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch bool parseDate(const String&, unsigned start, unsigned& end); 1105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Sets year and week. 111591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch bool parseWeek(const String&, unsigned start, unsigned& end); 1125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Sets hour, minute, second and millisecond. 113591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch bool parseTime(const String&, unsigned start, unsigned& end); 1145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Sets year, month, monthDay, hour, minute, second and millisecond. 115591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch bool parseDateTimeLocal(const String&, unsigned start, unsigned& end); 1165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Sets year, month, monthDay, hour, minute, second and millisecond, and adjusts timezone. 117591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch bool parseDateTime(const String&, unsigned start, unsigned& end); 1185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // The following setMillisecondsSinceEpochFor*() functions take 1205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // the number of milliseconds since 1970-01-01 00:00:00.000 UTC as 1215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // the argument, and update all fields for the corresponding 1225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // DateComponents type. The functions return true if it succeeds, and 1235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // false if they fail. 1245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // For Date type. Updates m_year, m_month and m_monthDay. 1265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) bool setMillisecondsSinceEpochForDate(double ms); 1275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // For DateTime type. Updates m_year, m_month, m_monthDay, m_hour, m_minute, m_second and m_millisecond. 1285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) bool setMillisecondsSinceEpochForDateTime(double ms); 1295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // For DateTimeLocal type. Updates m_year, m_month, m_monthDay, m_hour, m_minute, m_second and m_millisecond. 1305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) bool setMillisecondsSinceEpochForDateTimeLocal(double ms); 1315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // For Month type. Updates m_year and m_month. 1325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) bool setMillisecondsSinceEpochForMonth(double ms); 1335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // For Week type. Updates m_year and m_week. 1345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) bool setMillisecondsSinceEpochForWeek(double ms); 1355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // For Time type. Updates m_hour, m_minute, m_second and m_millisecond. 1375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) bool setMillisecondsSinceMidnight(double ms); 1385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Another initializer for Month type. Updates m_year and m_month. 1405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) bool setMonthsSinceEpoch(double months); 1417242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci // Another initializer for Week type. Updates m_year and m_week. 1427242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci bool setWeek(int year, int weekNumber); 1435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Returns the number of milliseconds from 1970-01-01 00:00:00 UTC. 1455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // For a DateComponents initialized with parseDateTimeLocal(), 1465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // millisecondsSinceEpoch() returns a value for UTC timezone. 1475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) double millisecondsSinceEpoch() const; 1485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Returns the number of months from 1970-01. 1495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Do not call this for types other than Month. 1505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) double monthsSinceEpoch() const; 1515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) static inline double invalidMilliseconds() { return std::numeric_limits<double>::quiet_NaN(); } 1525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Minimum and maxmimum limits for setMillisecondsSince*(), 1545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // setMonthsSinceEpoch(), millisecondsSinceEpoch(), and monthsSinceEpoch(). 1555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) static inline double minimumDate() { return -62135596800000.0; } // 0001-01-01T00:00Z 1565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) static inline double minimumDateTime() { return -62135596800000.0; } // ditto. 1575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) static inline double minimumMonth() { return (1 - 1970) * 12.0 + 1 - 1; } // 0001-01 1585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) static inline double minimumTime() { return 0; } // 00:00:00.000 1595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) static inline double minimumWeek() { return -62135596800000.0; } // 0001-01-01, the first Monday of 0001. 1605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) static inline double maximumDate() { return 8640000000000000.0; } // 275760-09-13T00:00Z 1615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) static inline double maximumDateTime() { return 8640000000000000.0; } // ditto. 1625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) static inline double maximumMonth() { return (275760 - 1970) * 12.0 + 9 - 1; } // 275760-09 1635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) static inline double maximumTime() { return 86399999; } // 23:59:59.999 1645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) static inline double maximumWeek() { return 8639999568000000.0; } // 275760-09-08, the Monday of the week including 275760-09-13. 1655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // HTML5 uses ISO-8601 format with year >= 1. Gregorian calendar started in 1675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // 1582. However, we need to support 0001-01-01 in Gregorian calendar rule. 1685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) static inline int minimumYear() { return 1; } 1695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Date in ECMAScript can't represent dates later than 275760-09-13T00:00Z. 1705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // So, we have the same upper limit in HTML5 date/time types. 1715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) static inline int maximumYear() { return 275760; } 1725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) static const int minimumWeekNumber; 1735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) static const int maximumWeekNumber; 1745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)private: 1765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Returns the maximum week number in this DateComponents's year. 1775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // The result is either of 52 and 53. 1785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) int maxWeekNumberInYear() const; 179591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch bool parseYear(const String&, unsigned start, unsigned& end); 1805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) bool addDay(int); 1815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) bool addMinute(int); 182591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch bool parseTimeZone(const String&, unsigned start, unsigned& end); 1835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Helper for millisecondsSinceEpoch(). 1845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) double millisecondsSinceEpochForTime() const; 1855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Helpers for setMillisecondsSinceEpochFor*(). 1865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) bool setMillisecondsSinceEpochForDateInternal(double ms); 1875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) void setMillisecondsSinceMidnightInternal(double ms); 1885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Helper for toString(). 1895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) String toStringForTime(SecondFormat) const; 1905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // m_weekDay values 1925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) enum { 1935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Sunday = 0, 1945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Monday, 1955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Tuesday, 1965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Wednesday, 1975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Thursday, 1985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Friday, 1995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Saturday, 2005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) }; 2015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) int m_millisecond; // 0 - 999 2035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) int m_second; 2045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) int m_minute; 2055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) int m_hour; 2065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) int m_monthDay; // 1 - 31 2075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) int m_month; // 0:January - 11:December 2085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) int m_year; // 1582 - 2095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) int m_week; // 1 - 53 2105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Type m_type; 2125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}; 2135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 215c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)} // namespace blink 2165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#endif // DateComponents_h 218