Adbase
Adinf C++ base library V2
adbase::Date Class Reference

日期工具类 More...

#include <Date.hpp>

Classes

struct  YearMonthDay
 

Public Member Functions

 Date ()
 Constucts an invalid Date. More...
 
 Date (int year, int month, int day)
 Constucts a yyyy-mm-dd Date. More...
 
 Date (int julianDayNum)
 Constucts a Date from Julian Day Number. More...
 
 Date (const struct tm &)
 Constucts a Date from struct tm. More...
 
void swap (Date &that)
 default copy/assignment/dtor are Okay More...
 
bool valid () const
 Date is valid. More...
 
::std::string toIsoString () const
 
struct YearMonthDay yearMonthDay () const
 
int year () const
 
int month () const
 
int day () const
 
int weekDay () const
 [0, 1, ..., 6] => [Sunday, Monday, ..., Saturday ] More...
 
int julianDayNumber () const
 

Static Public Attributes

static const int kDaysPerWeek = 7
 
static const int kJulianDayOf1970_01_01 = detail::getJulianDayNumber(1970, 1, 1)
 

Friends

bool operator< (Date x, Date y)
 
bool operator> (Date x, Date y)
 
bool operator== (Date x, Date y)
 

Detailed Description

日期工具类

Definition at line 20 of file Date.hpp.

Constructor & Destructor Documentation

adbase::Date::Date ( )
inline

Constucts an invalid Date.

Definition at line 32 of file Date.hpp.

References adbase::Date::YearMonthDay::day, adbase::Date::YearMonthDay::month, and adbase::Date::YearMonthDay::year.

Referenced by Date().

adbase::Date::Date ( int  year,
int  month,
int  day 
)

Constucts a yyyy-mm-dd Date.

Definition at line 41 of file Date.cpp.

adbase::Date::Date ( int  julianDayNum)
inlineexplicit

Constucts a Date from Julian Day Number.

Definition at line 38 of file Date.hpp.

References Date().

adbase::Date::Date ( const struct tm &  t)
explicit

Constucts a Date from struct tm.

Definition at line 47 of file Date.cpp.

Member Function Documentation

int adbase::Date::day ( ) const
inline

Definition at line 65 of file Date.hpp.

References adbase::Date::YearMonthDay::day, and yearMonthDay().

int adbase::Date::julianDayNumber ( ) const
inline

Definition at line 74 of file Date.hpp.

References operator<, operator==, and operator>.

Referenced by adbase::TimeZone::fromUtcTime(), and adbase::TimeZone::toUtcTime().

int adbase::Date::month ( ) const
inline

Definition at line 61 of file Date.hpp.

References adbase::Date::YearMonthDay::month, and yearMonthDay().

void adbase::Date::swap ( Date that)
inline

default copy/assignment/dtor are Okay

Definition at line 44 of file Date.hpp.

std::string adbase::Date::toIsoString ( ) const
bool adbase::Date::valid ( ) const
inline

Date is valid.

Definition at line 49 of file Date.hpp.

References toIsoString().

int adbase::Date::weekDay ( ) const
inline

[0, 1, ..., 6] => [Sunday, Monday, ..., Saturday ]

Definition at line 70 of file Date.hpp.

References kDaysPerWeek.

Referenced by adbase::TimeZone::toUtcTime().

int adbase::Date::year ( ) const
inline

Definition at line 57 of file Date.hpp.

References adbase::Date::YearMonthDay::year, and yearMonthDay().

Date::YearMonthDay adbase::Date::yearMonthDay ( ) const

Definition at line 68 of file Date.cpp.

References adbase::detail::getYearMonthDay().

Referenced by day(), month(), toIsoString(), adbase::TimeZone::toUtcTime(), and year().

Friends And Related Function Documentation

bool operator< ( Date  x,
Date  y 
)
friend

Definition at line 86 of file Date.hpp.

Referenced by julianDayNumber().

bool operator== ( Date  x,
Date  y 
)
friend

Definition at line 94 of file Date.hpp.

Referenced by julianDayNumber().

bool operator> ( Date  x,
Date  y 
)
friend

Definition at line 90 of file Date.hpp.

Referenced by julianDayNumber().

Member Data Documentation

const int adbase::Date::kDaysPerWeek = 7
static

Definition at line 28 of file Date.hpp.

Referenced by weekDay().

const int adbase::Date::kJulianDayOf1970_01_01 = detail::getJulianDayNumber(1970, 1, 1)
static

The documentation for this class was generated from the following files: