chromium/base/time/time_exploded_icu.cc

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/time/time.h"

#include <memory>

#include "base/check.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/numerics/clamped_math.h"
#include "build/build_config.h"
#include "third_party/icu/source/common/unicode/locid.h"
#include "third_party/icu/source/i18n/unicode/calendar.h"
#include "third_party/icu/source/i18n/unicode/gregocal.h"
#include "third_party/icu/source/i18n/unicode/timezone.h"

namespace base {

namespace {

// Returns a new icu::Calendar instance for the local time zone if |is_local|
// and for GMT otherwise. Returns null on error.
std::unique_ptr<icu::Calendar> CreateCalendar(bool is_local) {}

// Explodes the |millis_since_unix_epoch| using an icu::Calendar, and returns
// true if the conversion was successful.
bool ExplodeUsingIcuCalendar(int64_t millis_since_unix_epoch,
                             bool is_local,
                             Time::Exploded* exploded) {}

}  // namespace

// static
void Time::ExplodeUsingIcu(int64_t millis_since_unix_epoch,
                           bool is_local,
                           Exploded* exploded) {}

// static
bool Time::FromExplodedUsingIcu(bool is_local,
                                const Exploded& exploded,
                                int64_t* millis_since_unix_epoch) {}

#if BUILDFLAG(IS_FUCHSIA)

void Time::Explode(bool is_local, Exploded* exploded) const {
  return ExplodeUsingIcu(ToRoundedDownMillisecondsSinceUnixEpoch(), is_local,
                         exploded);
}

// static
bool Time::FromExploded(bool is_local, const Exploded& exploded, Time* time) {
  int64_t millis_since_unix_epoch;
  if (FromExplodedUsingIcu(is_local, exploded, &millis_since_unix_epoch))
    return FromMillisecondsSinceUnixEpoch(millis_since_unix_epoch, time);
  *time = Time(0);
  return false;
}

#endif  // BUILDFLAG(IS_FUCHSIA)

}  // namespace base