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

An encapsulation of 'struct std::tm'. More...

#include <gdatetime.h>

Public Member Functions

 BrokenDownTime (const struct std::tm &)
 Constructor. More...
 
 BrokenDownTime (int year, int month, int day, int hh, int mm, int ss)
 Constructor. More...
 
bool format (char *out, std::size_t out_size, const char *fmt) const
 Puts the formatted date, including a terminating null character, into the given output buffer. More...
 
void format (std::vector< char > &out, const char *fmt) const
 Overload for an output vector. More...
 
std::string str (const char *fmt) const
 Returns the formatted date, with the same restrictions as format(). More...
 
std::string str () const
 Returns str() using a "%F %T" format. More...
 
int year () const
 Returns the four-digit year value. More...
 
int month () const
 Returns the 1..12 month value. More...
 
int day () const
 Returns the 1..31 month-day value. More...
 
int hour () const
 Returns the 0..23 hour value. More...
 
int min () const
 Returns the 0..59 minute value. More...
 
int sec () const
 Returns the 0..59 or 0..60 seconds value. More...
 
int wday () const
 Returns week day where sunday=0 and saturday=6. More...
 
std::time_t epochTimeFromUtc () const
 Converts this utc broken-down time into epoch time. More...
 
std::time_t epochTimeFromLocal () const
 Uses std::mktime() to convert this locale-dependent local broken-down time into epoch time. More...
 
bool sameMinute (const BrokenDownTime &) const noexcept
 Returns true if this and the other broken-down times are the same, at minute resolution with no rounding. More...
 
bool operator== (const BrokenDownTime &) const noexcept
 Equality test. More...
 
bool operator!= (const BrokenDownTime &) const noexcept
 Inequality test. More...
 

Static Public Member Functions

static BrokenDownTime null ()
 Factory function for an unusable object with bogus component values. More...
 
static BrokenDownTime midday (int year, int month, int day)
 Factory function for midday on the given date. More...
 
static BrokenDownTime midnight (int year, int month, int day)
 Factory function for midnight starting the given date. More...
 
static BrokenDownTime local (SystemTime)
 Factory function for the locale-dependent local broken-down time of the given epoch time. More...
 
static BrokenDownTime utc (SystemTime)
 Factory function for the utc broken-down time of the given epoch time. More...
 

Friends

class G::DateTimeTest
 

Detailed Description

An encapsulation of 'struct std::tm'.

Definition at line 44 of file gdatetime.h.

Constructor & Destructor Documentation

◆ BrokenDownTime() [1/2]

G::BrokenDownTime::BrokenDownTime ( const struct std::tm &  tm_in)
explicit

Constructor.

Definition at line 145 of file gdatetime.cpp.

◆ BrokenDownTime() [2/2]

G::BrokenDownTime::BrokenDownTime ( int  year,
int  month,
int  day,
int  hh,
int  mm,
int  ss 
)

Constructor.

Definition at line 154 of file gdatetime.cpp.

Member Function Documentation

◆ day()

int G::BrokenDownTime::day ( ) const

Returns the 1..31 month-day value.

Definition at line 296 of file gdatetime.cpp.

◆ epochTimeFromLocal()

std::time_t G::BrokenDownTime::epochTimeFromLocal ( ) const

Uses std::mktime() to convert this locale-dependent local broken-down time into epoch time.

Definition at line 169 of file gdatetime.cpp.

◆ epochTimeFromUtc()

std::time_t G::BrokenDownTime::epochTimeFromUtc ( ) const

Converts this utc broken-down time into epoch time.

Definition at line 175 of file gdatetime.cpp.

◆ format() [1/2]

bool G::BrokenDownTime::format ( char *  out,
std::size_t  out_size,
const char *  fmt 
) const

Puts the formatted date, including a terminating null character, into the given output buffer.

Returns false if the output buffer is too small. Only simple non-locale-dependent format specifiers are allowed, and these allowed specifiers explicitly exclude 'z' and 'Z'.

Definition at line 232 of file gdatetime.cpp.

◆ format() [2/2]

void G::BrokenDownTime::format ( std::vector< char > &  out,
const char *  fmt 
) const

Overload for an output vector.

Throws if the vector is too small for the result (with its null terminator).

Definition at line 246 of file gdatetime.cpp.

◆ hour()

int G::BrokenDownTime::hour ( ) const

Returns the 0..23 hour value.

Definition at line 271 of file gdatetime.cpp.

◆ local()

G::BrokenDownTime G::BrokenDownTime::local ( SystemTime  t)
static

Factory function for the locale-dependent local broken-down time of the given epoch time.

See also SystemTime::local().

Definition at line 206 of file gdatetime.cpp.

◆ midday()

G::BrokenDownTime G::BrokenDownTime::midday ( int  year,
int  month,
int  day 
)
static

Factory function for midday on the given date.

Definition at line 220 of file gdatetime.cpp.

◆ midnight()

G::BrokenDownTime G::BrokenDownTime::midnight ( int  year,
int  month,
int  day 
)
static

Factory function for midnight starting the given date.

Definition at line 226 of file gdatetime.cpp.

◆ min()

int G::BrokenDownTime::min ( ) const

Returns the 0..59 minute value.

Definition at line 276 of file gdatetime.cpp.

◆ month()

int G::BrokenDownTime::month ( ) const

Returns the 1..12 month value.

Definition at line 291 of file gdatetime.cpp.

◆ null()

G::BrokenDownTime G::BrokenDownTime::null ( )
static

Factory function for an unusable object with bogus component values.

Definition at line 200 of file gdatetime.cpp.

◆ operator!=()

bool G::BrokenDownTime::operator!= ( const BrokenDownTime other) const
inlinenoexcept

Inequality test.

Definition at line 422 of file gdatetime.h.

◆ operator==()

bool G::BrokenDownTime::operator== ( const BrokenDownTime other) const
inlinenoexcept

Equality test.

Definition at line 417 of file gdatetime.h.

◆ sameMinute()

bool G::BrokenDownTime::sameMinute ( const BrokenDownTime other) const
noexcept

Returns true if this and the other broken-down times are the same, at minute resolution with no rounding.

Definition at line 309 of file gdatetime.cpp.

◆ sec()

int G::BrokenDownTime::sec ( ) const

Returns the 0..59 or 0..60 seconds value.

Definition at line 281 of file gdatetime.cpp.

◆ str() [1/2]

std::string G::BrokenDownTime::str ( ) const

Returns str() using a "%F %T" format.

Definition at line 253 of file gdatetime.cpp.

◆ str() [2/2]

std::string G::BrokenDownTime::str ( const char *  fmt) const

Returns the formatted date, with the same restrictions as format().

Definition at line 259 of file gdatetime.cpp.

◆ utc()

G::BrokenDownTime G::BrokenDownTime::utc ( SystemTime  t)
static

Factory function for the utc broken-down time of the given epoch time.

See also SystemTime::utc().

Definition at line 213 of file gdatetime.cpp.

◆ wday()

int G::BrokenDownTime::wday ( ) const

Returns week day where sunday=0 and saturday=6.

Definition at line 301 of file gdatetime.cpp.

◆ year()

int G::BrokenDownTime::year ( ) const

Returns the four-digit year value.

Definition at line 286 of file gdatetime.cpp.

Friends And Related Function Documentation

◆ G::DateTimeTest

friend class G::DateTimeTest
friend

Definition at line 132 of file gdatetime.h.


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