libDwm-0.9.45
Dwm::TimeUtil Class Reference

This class is just a collection of time utility functions. More...

#include <DwmTimeUtil.hh>

Static Public Member Functions

static void GmTime (time_t unixsecs, struct tm &result)
 This is just a convenient wrapper for gmtime(time_t *) that stores the result in result.
 
static void LocalTime (time_t unixsecs, struct tm &result)
 This is just a convenient wrapper for localtime(time_t *) that stores the result in result.
 
static bool SubtractTimeval (const struct timeval &lhs, const struct timeval &rhs, struct timeval &result)
 Subtracts rhs from lhs and places the result in result.
 
static bool ParseDateTime (const std::string &dateTimeString, struct tm &tm)
 Parses dateTimeString and stores the resulting time in tm.
 
static bool ParseDateTime (const std::string &dateTimeString, time_t &t)
 Parses dateTimeString and stores the resulting time in t.
 
static time_t MidnightDaysLater (int daysLater)
 Returns the time for midnight (00:00) at the given daysLater.
 

Detailed Description

This class is just a collection of time utility functions.

Member Function Documentation

◆ MidnightDaysLater()

static time_t Dwm::TimeUtil::MidnightDaysLater ( int daysLater)
static

Returns the time for midnight (00:00) at the given daysLater.

For example, if daysLater is 1, we'll return the upcoming midnight time (useful when rolling over log files, etc.).

◆ ParseDateTime() [1/2]

static bool Dwm::TimeUtil::ParseDateTime ( const std::string & dateTimeString,
struct tm & tm )
static

Parses dateTimeString and stores the resulting time in tm.

Returns true on success, false on failure. dateTimeString must contain a date of one of the following forms:

YYYYMMDD YYYY/MM/DD MM/DD/YYYY Jan DD, YYYY Jan DD YYYY

dataTimeString may have a space and a time after the date, where the time must be of the form HH:MM:SS (minutes and seconds are optional, and will default to 0 if not specified).

◆ ParseDateTime() [2/2]

static bool Dwm::TimeUtil::ParseDateTime ( const std::string & dateTimeString,
time_t & t )
static

Parses dateTimeString and stores the resulting time in t.

Returns true on success, false on failure. dateTimeString must contain a date of one of the following forms:

YYYYMMDD YYYY/MM/DD MM/DD/YYYY Jan DD, YYYY Jan DD YYYY

dataTimeString may have a space and a time after the date, where the time must be of the form HH:MM:SS (minutes and seconds are optional, and will default to 0 if not specified).

◆ SubtractTimeval()

static bool Dwm::TimeUtil::SubtractTimeval ( const struct timeval & lhs,
const struct timeval & rhs,
struct timeval & result )
static

Subtracts rhs from lhs and places the result in result.

Returns true if the result is positive (lhs greater than rhs), else returns false.


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