Google APIs Client Library for C++

Represents a date convertable among various standard date represenations including RFC 3339 used by JSON encodings. More...

#include "client/util/date_time.h"

List of all members.

Public Member Functions

 DateTime ()
 Construct a date with the current time.
 DateTime (const string &date)
 Construct a date from an RFC 3339 formatted string.
 DateTime (time_t time)
 Construct a date from an epoch time.
 DateTime (const struct timeval &time)
 Construct a date from a timeval.
 DateTime (const DateTime &date)
 Copy constructor.
 ~DateTime ()
 Standard destructor.
string ToString () const
 Convert the data to an RFC 3330 encoded string.
void GetLocalTime (struct tm *out) const
 Convert the date to local time.
void GetUniversalTime (struct tm *out) const
 Convert the date to universal time.
void GetTimeval (struct timeval *timeval) const
time_t ToEpochTime () const
 Convert the date to epoch time.
bool is_valid () const
 Determine if we have a valid date or not.
int Compare (const DateTime &date) const
 Determine relative ordering of this date relative to another.
bool operator== (const DateTime &date) const
 Determine if this date is equal to another.
bool operator< (const DateTime &date) const
 Determine if this date is earlier than another.
bool operator> (const DateTime &date) const
 Determine if this date is later than another.
bool operator!= (const DateTime &date) const
 Determine if this date is different from another.
bool operator<= (const DateTime &date) const
 Determine if this earlier or equal to another.
bool operator>= (const DateTime &date) const
 Determine if this later or equal to another.
DateTimeoperator= (const DateTime &date)
 Reasign this date to another.

Static Public Member Functions

static DateTime DateTimeFromUtc (const struct tm &utc)
 Construct a date from a UTC struct tm.
static DateTime DateTimeFromLocal (const struct tm &local)
 Construct a date from a local-time struct tm.

Protected Member Functions

void MarkInvalid ()
 Marks this date as being invalid.
 DateTime (const struct tm &local)
 Construct the data from a struct tm that is in local time.

Protected Attributes

struct timeval t_

Static Protected Attributes

static const time_t kInvalidEpoch_

Detailed Description

Represents a date convertable among various standard date represenations including RFC 3339 used by JSON encodings.


Constructor & Destructor Documentation

DateTime ( )

Construct a date with the current time.

DateTime ( const string &  date) [explicit]

Construct a date from an RFC 3339 formatted string.

DateTime ( time_t  time) [explicit]

Construct a date from an epoch time.

DateTime ( const struct timeval &  time) [explicit]

Construct a date from a timeval.

Parameters:
[in]timeCan contain fractional seconds.
DateTime ( const DateTime date)

Copy constructor.

~DateTime ( )

Standard destructor.

DateTime ( const struct tm &  local) [explicit, protected]

Construct the data from a struct tm that is in local time.

This constructir is exposed through the public factory methods the struct tm is in.


Member Function Documentation

int Compare ( const DateTime date) const [inline]

Determine relative ordering of this date relative to another.

Parameters:
[in]dateThe date to compare against
Returns:
< 0 if this date is earlier, > 0 if this date is later, or 0 if the dates are equal.
static DateTime DateTimeFromLocal ( const struct tm &  local) [inline, static]

Construct a date from a local-time struct tm.

Returns:
An invalid date if the specified time is not valid.
See also:
DateTimeFromUTC
static DateTime DateTimeFromUtc ( const struct tm &  utc) [static]

Construct a date from a UTC struct tm.

Returns:
An invalid date if the specified time is not valid.
See also:
DateTimeFromLocal
void GetLocalTime ( struct tm *  out) const [inline]

Convert the date to local time.

void GetTimeval ( struct timeval *  timeval) const [inline]
void GetUniversalTime ( struct tm *  out) const [inline]

Convert the date to universal time.

bool is_valid ( ) const [inline]

Determine if we have a valid date or not.

void MarkInvalid ( ) [protected]

Marks this date as being invalid.

bool operator!= ( const DateTime date) const [inline]

Determine if this date is different from another.

bool operator< ( const DateTime date) const [inline]

Determine if this date is earlier than another.

bool operator<= ( const DateTime date) const [inline]

Determine if this earlier or equal to another.

DateTime& operator= ( const DateTime date) [inline]

Reasign this date to another.

bool operator== ( const DateTime date) const [inline]

Determine if this date is equal to another.

bool operator> ( const DateTime date) const [inline]

Determine if this date is later than another.

bool operator>= ( const DateTime date) const [inline]

Determine if this later or equal to another.

time_t ToEpochTime ( ) const [inline]

Convert the date to epoch time.

string ToString ( ) const

Convert the data to an RFC 3330 encoded string.


Member Data Documentation

const time_t kInvalidEpoch_ [static, protected]
struct timeval t_ [protected]

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines