libDwm-0.9.45
Dwm::DateTime Class Reference

This class just encapsulates a struct tm and some of the typical functionality for dealing with date and time. More...

#include <DwmDateTime.hh>

Public Member Functions

 DateTime (bool now=false)
 Constructor.
 
 DateTime (const TimeValue &tv)
 Construct from a TimeValue.
 
 DateTime (const Dwm::TimeValue64 &tv)
 Construct from a TimeValue64.
 
TimeValue GetTimeValue () const
 Return the equivalent TimeValue, using the current timezone setting.
 
TimeValue64 GetTimeValue64 () const
 Return the equivalent TimeValue64, using the current timezone setting.
 
bool IsDaylightSavings () const
 Returns true if daylight savings is in effect.
 
uint8_t Sec () const
 Returns the seconds (0 - 59).
 
uint8_t Min () const
 Returns the minutes (0 - 59).
 
uint8_t Hour () const
 Returns the hour (0 - 23).
 
uint8_t DayOfMonth () const
 Returns the day of the month (1 - 31).
 
uint8_t Month () const
 Returns the month of the year (1 - 12).
 
uint16_t Year () const
 Returns the year.
 
uint8_t DayOfWeek () const
 Returns the day of the week (Sunday == 0)
 
uint16_t DayOfYear () const
 Returns the day of the year (0 - 365).
 
std::string TimeZone () const
 Returns the time zone.
 
std::string Formatted (const std::string &format) const
 Returns a string formatted according to format.
 
bool Parse (const std::string &s, const std::string &format)
 Parses time string s according to the given format.
 
bool operator== (const DateTime &dt) const
 operator ==
 
bool operator< (const DateTime &dt) const
 operator <
 

Detailed Description

This class just encapsulates a struct tm and some of the typical functionality for dealing with date and time.

Note that we always initialize using the local timezone.

Constructor & Destructor Documentation

◆ DateTime()

Dwm::DateTime::DateTime ( bool now = false)

Constructor.

Will initialize to the UNIX epoch if now is false, otherwise will initialize ot the current time.

Member Function Documentation

◆ Formatted()

std::string Dwm::DateTime::Formatted ( const std::string & format) const

Returns a string formatted according to format.

This just calls strftime() under the hood; see the strftime() manpage.

◆ Parse()

bool Dwm::DateTime::Parse ( const std::string & s,
const std::string & format )

Parses time string s according to the given format.

Returns tree on success.

Note
This calls strptime() under the hood; see the strptime() manpage.

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