E-MailRelay
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
G::Date Class Reference

A day-month-year date class. More...

#include <gdate.h>

Classes

class  LocalTime
 An overload discriminator class for Date constructors. More...
 

Public Types

enum class  Weekday {
  sunday , monday , tuesday , wednesday ,
  thursday , friday , saturday
}
 
enum class  Month {
  january = 1 , february , march , april ,
  may , june , july , august ,
  september , october , november , december
}
 
enum class  Format { yyyy_mm_dd_slash , yyyy_mm_dd , mm_dd }
 

Public Member Functions

 Date ()
 Default constructor for the current date in the UTC timezone. More...
 
 Date (const LocalTime &)
 Constructor for the current date in the local timezone. More...
 
 Date (const BrokenDownTime &tm)
 Constructor for the specified date. More...
 
 Date (SystemTime t)
 Constructor for the date in the UTC timezone as at the given epoch time. More...
 
 Date (SystemTime t, const LocalTime &)
 Constructor for the date in the local timezone as at the given epoch time. More...
 
 Date (int year, Month month, int day_of_month)
 Constructor for the specified date. More...
 
 Date (int year, Month month, int day_of_month, std::nothrow_t) noexcept
 Constructor for the specified date. More...
 
std::string str (Format format=Format::yyyy_mm_dd_slash) const
 Returns a string representation of the date. More...
 
Weekday weekday () const
 Returns the day of the week. More...
 
std::string weekdayName (bool brief=false) const
 Returns an english string representation of the day of the week. More...
 
int monthday () const
 Returns the day of the month. More...
 
std::string dd () const
 Returns the day of the month as a two-digit decimal string. More...
 
Month month () const
 Returns the month. More...
 
std::string monthName (bool brief=false) const
 Returns the month as a string (in english). More...
 
std::string mm () const
 Returns the month as a two-digit decimal string. More...
 
int year () const
 Returns the year. More...
 
std::string yyyy () const
 Returns the year as a four-digit decimal string. More...
 
Date next () const
 Returns the next date. More...
 
Date previous () const
 Returns the previous date. More...
 
Dateoperator++ ()
 Increments the date by one day. More...
 
Dateoperator-- ()
 Decrements the date by one day. More...
 
bool operator== (const Date &rhs) const
 Comparison operator. More...
 
bool operator!= (const Date &rhs) const
 Comparison operator. More...
 

Static Public Member Functions

static int yearUpperLimit () noexcept
 Returns the largest supported year value. More...
 
static int yearLowerLimit () noexcept
 Returns the smallest supported year value. More...
 

Detailed Description

A day-month-year date class.

See also
G::Time, G::DateTime

Definition at line 41 of file gdate.h.

Member Enumeration Documentation

◆ Format

enum class G::Date::Format
strong

Definition at line 52 of file gdate.h.

◆ Month

enum class G::Date::Month
strong

Definition at line 50 of file gdate.h.

◆ Weekday

enum class G::Date::Weekday
strong

Definition at line 48 of file gdate.h.

Constructor & Destructor Documentation

◆ Date() [1/7]

G::Date::Date ( )

Default constructor for the current date in the UTC timezone.

Definition at line 40 of file gdate.cpp.

◆ Date() [2/7]

G::Date::Date ( const LocalTime )
explicit

Constructor for the current date in the local timezone.

Definition at line 70 of file gdate.cpp.

◆ Date() [3/7]

G::Date::Date ( const BrokenDownTime tm)
explicit

Constructor for the specified date.

Definition at line 63 of file gdate.cpp.

◆ Date() [4/7]

G::Date::Date ( SystemTime  t)
explicit

Constructor for the date in the UTC timezone as at the given epoch time.

Definition at line 48 of file gdate.cpp.

◆ Date() [5/7]

G::Date::Date ( SystemTime  t,
const LocalTime  
)

Constructor for the date in the local timezone as at the given epoch time.

Definition at line 56 of file gdate.cpp.

◆ Date() [6/7]

G::Date::Date ( int  year,
Date::Month  month,
int  day_of_month 
)

Constructor for the specified date.

Throws if out of range.

Definition at line 90 of file gdate.cpp.

◆ Date() [7/7]

G::Date::Date ( int  year,
Date::Month  month,
int  day_of_month,
std::nothrow_t   
)
noexcept

Constructor for the specified date.

Definition at line 78 of file gdate.cpp.

Member Function Documentation

◆ dd()

std::string G::Date::dd ( ) const

Returns the day of the month as a two-digit decimal string.

Definition at line 148 of file gdate.cpp.

◆ mm()

std::string G::Date::mm ( ) const

Returns the month as a two-digit decimal string.

Definition at line 153 of file gdate.cpp.

◆ month()

G::Date::Month G::Date::month ( ) const

Returns the month.

Definition at line 188 of file gdate.cpp.

◆ monthday()

int G::Date::monthday ( ) const

Returns the day of the month.

Definition at line 143 of file gdate.cpp.

◆ monthName()

std::string G::Date::monthName ( bool  brief = false) const

Returns the month as a string (in english).

Definition at line 193 of file gdate.cpp.

◆ next()

G::Date G::Date::next ( ) const

Returns the next date.

Definition at line 218 of file gdate.cpp.

◆ operator!=()

bool G::Date::operator!= ( const Date rhs) const

Comparison operator.

Definition at line 322 of file gdate.cpp.

◆ operator++()

G::Date & G::Date::operator++ ( )

Increments the date by one day.

Definition at line 226 of file gdate.cpp.

◆ operator--()

G::Date & G::Date::operator-- ( )

Decrements the date by one day.

Definition at line 258 of file gdate.cpp.

◆ operator==()

bool G::Date::operator== ( const Date rhs) const

Comparison operator.

Definition at line 313 of file gdate.cpp.

◆ previous()

G::Date G::Date::previous ( ) const

Returns the previous date.

Definition at line 250 of file gdate.cpp.

◆ str()

std::string G::Date::str ( Format  format = Format::yyyy_mm_dd_slash) const

Returns a string representation of the date.

Definition at line 120 of file gdate.cpp.

◆ weekday()

G::Date::Weekday G::Date::weekday ( ) const

Returns the day of the week.

Definition at line 163 of file gdate.cpp.

◆ weekdayName()

std::string G::Date::weekdayName ( bool  brief = false) const

Returns an english string representation of the day of the week.

Definition at line 174 of file gdate.cpp.

◆ year()

int G::Date::year ( ) const

Returns the year.

Definition at line 212 of file gdate.cpp.

◆ yearLowerLimit()

int G::Date::yearLowerLimit ( )
staticnoexcept

Returns the smallest supported year value.

Definition at line 34 of file gdate.cpp.

◆ yearUpperLimit()

int G::Date::yearUpperLimit ( )
staticnoexcept

Returns the largest supported year value.

Definition at line 28 of file gdate.cpp.

◆ yyyy()

std::string G::Date::yyyy ( ) const

Returns the year as a four-digit decimal string.

Definition at line 158 of file gdate.cpp.


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