66 m_month(static_cast<int>(month)) ,
71 G_ASSERT( day_of_month > 0 ) ;
72 G_ASSERT( day_of_month < 32 ) ;
73 G_ASSERT(
static_cast<int>(
month) >= 1 ) ;
74 G_ASSERT(
static_cast<int>(
month) <= 12 ) ;
80 m_month = tm.
month() ;
86 std::ostringstream ss ;
87 if(
format == Format::yyyy_mm_dd_slash )
89 ss << yyyy() <<
"/" << mm() <<
"/" << dd() ;
91 else if(
format == Format::yyyy_mm_dd )
93 ss << yyyy() << mm() << dd() ;
95 else if(
format == Format::mm_dd )
101 G_ASSERT( !
"enum error" ) ;
113 std::ostringstream ss ;
114 ss << std::setw(2) << std::setfill(
'0') << m_day ;
120 std::ostringstream ss ;
121 ss << std::setw(2) << std::setfill(
'0') << m_month ;
127 if( ! m_weekday_set )
130 const_cast<Date*
>(
this)->m_weekday_set =
true ;
131 const_cast<Date*
>(
this)->m_weekday = Weekday(bdt.
wday()) ;
138 if( weekday() == Weekday::sunday )
return brief ?
"Sun" :
"Sunday" ;
139 if( weekday() == Weekday::monday )
return brief ?
"Mon" :
"Monday" ;
140 if( weekday() == Weekday::tuesday )
return brief ?
"Tue" :
"Tuesday" ;
141 if( weekday() == Weekday::wednesday )
return brief ?
"Wed" :
"Wednesday" ;
142 if( weekday() == Weekday::thursday )
return brief ?
"Thu" :
"Thursday" ;
143 if( weekday() == Weekday::friday )
return brief ?
"Fri" :
"Friday" ;
144 if( weekday() == Weekday::saturday )
return brief ?
"Sat" :
"Saturday" ;
150 return Month(m_month) ;
155 if( month() == Month::january )
return brief ?
"Jan" :
"January" ;
156 if( month() == Month::february )
return brief ?
"Feb" :
"February" ;
157 if( month() == Month::march )
return brief ?
"Mar" :
"March" ;
158 if( month() == Month::april )
return brief ?
"Apr" :
"April" ;
159 if( month() == Month::may )
return "May" ;
160 if( month() == Month::june )
return brief ?
"Jun" :
"June" ;
161 if( month() == Month::july )
return brief ?
"Jul" :
"July" ;
162 if( month() == Month::august )
return brief ?
"Aug" :
"August" ;
163 if( month() == Month::september )
return brief ?
"Sep" :
"September" ;
164 if( month() == Month::october )
return brief ?
"Oct" :
"October" ;
165 if( month() == Month::november )
return brief ?
"Nov" :
"November" ;
166 if( month() == Month::december )
return brief ?
"Dec" :
"December" ;
177 std::ostringstream ss ;
178 ss << std::setw(4) << std::setfill(
'0') << m_year ;
185 if( m_day == (lastDay(m_month,m_year)+1) )
197 if( m_weekday == Weekday::saturday )
198 m_weekday = Weekday::sunday ;
200 m_weekday =
static_cast<Weekday
>(
static_cast<int>(m_weekday)+1) ;
219 m_day = lastDay( m_month , m_year ) ;
227 if( m_weekday == Weekday::sunday )
228 m_weekday = Weekday::saturday ;
230 m_weekday =
static_cast<Weekday
>(
static_cast<int>(m_weekday)-1) ;
235int G::Date::lastDay(
int month ,
int year )
248 else if( month == 2 )
250 end = isLeapYear(year) ? 29 : 28 ;
255bool G::Date::isLeapYear(
int y )
257 return y >= 1800 && ( y % 400 == 0 || ( y % 100 != 0 && y % 4 == 0 ) ) ;
263 year() == other.
year() &&
264 month() == other.
month() &&
270 return !( other == *this ) ;
An encapsulation of 'struct std::tm'.
int wday() const
Returns week day where sunday=0 and saturday=6.
int day() const
Returns the 1..31 month-day value.
static BrokenDownTime midday(int year, int month, int day)
Factory function for midday on the given date.
int month() const
Returns the 1..12 month value.
int year() const
Returns the four-digit year value.
An overload discriminator class for Date constructors.
A day-month-year date class.
Date()
Default constructor for the current date in the UTC timezone.
Date & operator--()
Decrements the date by one day.
std::string monthName(bool brief=false) const
Returns the month as a string (in english).
std::string weekdayName(bool brief=false) const
Returns an english string representation of the day of the week.
bool operator==(const Date &rhs) const
Comparison operator.
Month month() const
Returns the month.
static int yearUpperLimit()
Returns the largest supported year value.
int monthday() const
Returns the day of the month.
Date & operator++()
Increments the date by one day.
std::string yyyy() const
Returns the year as a four-digit decimal string.
std::string dd() const
Returns the day of the month as a two-digit decimal string.
std::string str(Format format=Format::yyyy_mm_dd_slash) const
Returns a string representation of the date.
Weekday weekday() const
Returns the day of the week.
bool operator!=(const Date &rhs) const
Comparison operator.
static int yearLowerLimit()
Returns the smallest supported year value.
int year() const
Returns the year.
std::string mm() const
Returns the month as a two-digit decimal string.
Represents a unix-epoch time with microsecond resolution.
static SystemTime now()
Factory function for the current time.
BrokenDownTime local() const
Returns the locale-dependent local broken-down time.
BrokenDownTime utc() const
Returns the utc broken-down time.