chromium/third_party/blink/renderer/platform/text/date_components.cc

/*
 * Copyright (C) 2009 Google Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *
 *     * Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above
 * copyright notice, this list of conditions and the following disclaimer
 * in the documentation and/or other materials provided with the
 * distribution.
 *     * Neither the name of Google Inc. nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "third_party/blink/renderer/platform/text/date_components.h"

#include <limits.h>
#include "base/notreached.h"
#include "third_party/blink/renderer/platform/wtf/date_math.h"
#include "third_party/blink/renderer/platform/wtf/math_extras.h"
#include "third_party/blink/renderer/platform/wtf/text/ascii_ctype.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"

namespace blink {

// HTML5 specification defines minimum week of year is one.
const int DateComponents::kMinimumWeekNumber =;

// HTML5 specification defines maximum week of year is 53.
const int DateComponents::kMaximumWeekNumber =;

// This is September, since months are 0 based.
static const int kMaximumMonthInMaximumYear =;
static const int kMaximumDayInMaximumMonth =;
static const int kMaximumWeekInMaximumYear =;  // The week of 275760-09-13

static const int kDaysInMonth[12] =;

// 'month' is 0-based.
static int MaxDayOfMonth(int year, int month) {}

// 'month' is 0-based.
static int DayOfWeek(int year, int month, int day) {}

int DateComponents::WeekDay() const {}

int DateComponents::MaxWeekNumberInYear() const {}

static unsigned CountDigits(const String& src, unsigned start) {}

// Very strict integer parser. Do not allow leading or trailing whitespace
// unlike charactersToIntStrict().
static bool ToInt(const String& src,
                  unsigned parse_start,
                  unsigned parse_length,
                  int& out) {}

bool DateComponents::ParseYear(const String& src,
                               unsigned start,
                               unsigned& end) {}

static bool WithinHTMLDateLimits(int year, int month) {}

static bool WithinHTMLDateLimits(int year, int month, int month_day) {}

static bool WithinHTMLDateLimits(int year,
                                 int month,
                                 int month_day,
                                 int hour,
                                 int minute,
                                 int second,
                                 int millisecond) {}

bool DateComponents::ParseMonth(const String& src,
                                unsigned start,
                                unsigned& end) {}

bool DateComponents::ParseDate(const String& src,
                               unsigned start,
                               unsigned& end) {}

bool DateComponents::ParseWeek(const String& src,
                               unsigned start,
                               unsigned& end) {}

bool DateComponents::ParseTime(const String& src,
                               unsigned start,
                               unsigned& end) {}

bool DateComponents::ParseDateTimeLocal(const String& src,
                                        unsigned start,
                                        unsigned& end) {}

static inline double PositiveFmod(double value, double divider) {}

void DateComponents::SetMillisecondsSinceMidnightInternal(double ms_in_day) {}

bool DateComponents::SetMillisecondsSinceEpochForDateInternal(double ms) {}

bool DateComponents::SetMillisecondsSinceEpochForDate(double ms) {}

bool DateComponents::SetMillisecondsSinceEpochForDateTimeLocal(double ms) {}

bool DateComponents::SetMillisecondsSinceEpochForMonth(double ms) {}

bool DateComponents::SetMillisecondsSinceMidnight(double ms) {}

bool DateComponents::SetMonthsSinceEpoch(double months) {}

// Offset from January 1st to Monday of the ISO 8601's first week.
//   ex. If January 1st is Friday, such Monday is 3 days later. Returns 3.
static int OffsetTo1stWeekStart(int year) {}

bool DateComponents::SetMillisecondsSinceEpochForWeek(double ms) {}

bool DateComponents::SetWeek(int year, int week_number) {}

double DateComponents::MillisecondsSinceEpochForTime() const {}

double DateComponents::MillisecondsSinceEpoch() const {}

double DateComponents::MonthsSinceEpoch() const {}

String DateComponents::ToStringForTime(SecondFormat format) const {}

String DateComponents::ToString(SecondFormat format) const {}

}  // namespace blink