11#include <userver/formats/common/meta.hpp> 
   13USERVER_NAMESPACE_BEGIN
 
   30  using Days = std::chrono::duration<
long long, std::ratio<86400>>;
 
   31  using SysDays = std::chrono::time_point<std::chrono::system_clock, Days>;
 
   34  Date(
const Date&) 
noexcept = 
default;
 
   35  Date& operator=(
const Date&) 
noexcept = 
default;
 
   38  Date(
int year, 
int month, 
int day);
 
   50  constexpr explicit operator SysDays() 
const { 
return sys_days_; }
 
   52  constexpr bool operator==(Date other) 
const {
 
   53    return sys_days_ == other.sys_days_;
 
   55  constexpr bool operator!=(Date other) 
const { 
return !(*
this == other); }
 
   67template <
typename Value>
 
   68std::enable_if_t<formats::common::kIsFormatValue<Value>, Date> Parse(
 
   69    const Value& value, formats::parse::To<Date>) {
 
   72    str = value.
template As<std::string>();
 
   73  } 
catch (
const std::exception& e) {
 
   74    throw typename Value::ParseException(
 
   75        "Only strings can be parsed as `utils::datetime::Date`");
 
   79    return utils::datetime::DateFromRFC3339String(str);
 
   80  } 
catch (
const std::exception& e) {
 
   81    throw typename Value::ParseException(
 
   82        "'" + str + 
"' cannot be parsed to `utils::datetime::Date`");
 
   86template <
typename Value>
 
   87std::enable_if_t<formats::common::kIsFormatValue<Value>, Value> Serialize(
 
   88    Date date, formats::serialize::To<Value>) {
 
   89  return typename Value::Builder(
ToString(date
)).ExtractValue();
 
   92template <
typename StringBuilder>
 
   93void WriteToStream(Date value, StringBuilder& sw) {
 
   97template <
typename LogHelper = USERVER_NAMESPACE::
logging::LogHelper>
 
   98USERVER_NAMESPACE::
logging::LogHelper& operator<<(
 
   99    USERVER_NAMESPACE::
logging::LogHelper& lh, 
const Date& date) {
 
  101      std::is_same_v<LogHelper, USERVER_NAMESPACE::
logging::LogHelper>,
 
  102      "This was made template to work well with forward declared " 
  103      "logging::LogHelper");
 
  104  return static_cast<LogHelper&>(lh) << 
ToString(date
);
 
  107std::ostream& operator<<(std::ostream& os, Date date);