chromium/third_party/abseil-cpp/absl/time/time.cc

// Copyright 2017 The Abseil Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// The implementation of the absl::Time class, which is declared in
// //absl/time.h.
//
// The representation for an absl::Time is an absl::Duration offset from the
// epoch.  We use the traditional Unix epoch (1970-01-01 00:00:00 +0000)
// for convenience, but this is not exposed in the API and could be changed.
//
// NOTE: To keep type verbosity to a minimum, the following variable naming
// conventions are used throughout this file.
//
// tz: An absl::TimeZone
// ci: An absl::TimeZone::CivilInfo
// ti: An absl::TimeZone::TimeInfo
// cd: An absl::CivilDay or a cctz::civil_day
// cs: An absl::CivilSecond or a cctz::civil_second
// bd: An absl::Time::Breakdown
// cl: A cctz::time_zone::civil_lookup
// al: A cctz::time_zone::absolute_lookup

#include "absl/time/time.h"

#if defined(_MSC_VER)
#include <winsock2.h>  // for timeval
#endif

#include <cstring>
#include <ctime>
#include <limits>

#include "absl/time/internal/cctz/include/cctz/civil_time.h"
#include "absl/time/internal/cctz/include/cctz/time_zone.h"

cctz;

namespace absl {
ABSL_NAMESPACE_BEGIN

namespace {

inline cctz::time_point<cctz::seconds> unix_epoch() {}

// Floors d to the next unit boundary closer to negative infinity.
inline int64_t FloorToUnit(absl::Duration d, absl::Duration unit) {}

ABSL_INTERNAL_DISABLE_DEPRECATED_DECLARATION_WARNING
inline absl::Time::Breakdown InfiniteFutureBreakdown() {}

inline absl::Time::Breakdown InfinitePastBreakdown() {}
ABSL_INTERNAL_RESTORE_DEPRECATED_DECLARATION_WARNING

inline absl::TimeZone::CivilInfo InfiniteFutureCivilInfo() {}

inline absl::TimeZone::CivilInfo InfinitePastCivilInfo() {}

ABSL_INTERNAL_DISABLE_DEPRECATED_DECLARATION_WARNING
inline absl::TimeConversion InfiniteFutureTimeConversion() {}

inline TimeConversion InfinitePastTimeConversion() {}
ABSL_INTERNAL_RESTORE_DEPRECATED_DECLARATION_WARNING

// Makes a Time from sec, overflowing to InfiniteFuture/InfinitePast as
// necessary. If sec is min/max, then consult cs+tz to check for overflow.
Time MakeTimeWithOverflow(const cctz::time_point<cctz::seconds>& sec,
                          const cctz::civil_second& cs,
                          const cctz::time_zone& tz,
                          bool* normalized = nullptr) {}

// Returns Mon=1..Sun=7.
inline int MapWeekday(const cctz::weekday& wd) {}

bool FindTransition(const cctz::time_zone& tz,
                    bool (cctz::time_zone::*find_transition)(
                        const cctz::time_point<cctz::seconds>& tp,
                        cctz::time_zone::civil_transition* trans) const,
                    Time t, TimeZone::CivilTransition* trans) {}

}  // namespace

//
// Time
//

ABSL_INTERNAL_DISABLE_DEPRECATED_DECLARATION_WARNING
absl::Time::Breakdown Time::In(absl::TimeZone tz) const {}
ABSL_INTERNAL_RESTORE_DEPRECATED_DECLARATION_WARNING

//
// Conversions from/to other time types.
//

absl::Time FromUDate(double udate) {}

absl::Time FromUniversal(int64_t universal) {}

int64_t ToUnixNanos(Time t) {}

int64_t ToUnixMicros(Time t) {}

int64_t ToUnixMillis(Time t) {}

int64_t ToUnixSeconds(Time t) {}

time_t ToTimeT(Time t) {}

double ToUDate(Time t) {}

int64_t ToUniversal(absl::Time t) {}

absl::Time TimeFromTimespec(timespec ts) {}

absl::Time TimeFromTimeval(timeval tv) {}

timespec ToTimespec(Time t) {}

timeval ToTimeval(Time t) {}

Time FromChrono(const std::chrono::system_clock::time_point& tp) {}

std::chrono::system_clock::time_point ToChronoTime(absl::Time t) {}

//
// TimeZone
//

absl::TimeZone::CivilInfo TimeZone::At(Time t) const {}

absl::TimeZone::TimeInfo TimeZone::At(CivilSecond ct) const {}

bool TimeZone::NextTransition(Time t, CivilTransition* trans) const {}

bool TimeZone::PrevTransition(Time t, CivilTransition* trans) const {}

//
// Conversions involving time zones.
//
ABSL_INTERNAL_DISABLE_DEPRECATED_DECLARATION_WARNING
absl::TimeConversion ConvertDateTime(int64_t year, int mon, int day, int hour,
                                     int min, int sec, TimeZone tz) {}
ABSL_INTERNAL_RESTORE_DEPRECATED_DECLARATION_WARNING

absl::Time FromTM(const struct tm& tm, absl::TimeZone tz) {}

struct tm ToTM(absl::Time t, absl::TimeZone tz) {}

ABSL_NAMESPACE_END
}  // namespace absl