ews-cpp  0.9
Public Member Functions | Static Public Member Functions | Friends | List of all members
ews::date_time Class Referencefinal

A thin wrapper around xs:dateTime formatted strings. More...

#include <ews.hpp>

Public Member Functions

 date_time (std::string str)
 
bool is_set () const EWS_NOEXCEPT
 
time_t to_epoch () const
 
const std::string & to_string () const EWS_NOEXCEPT
 

Static Public Member Functions

static date_time from_epoch (time_t epoch)
 

Friends

bool operator== (const date_time &, const date_time &)
 

Detailed Description

A thin wrapper around xs:dateTime formatted strings.

Microsoft EWS uses date and date/time string representations as described in https://www.w3.org/TR/xmlschema-2/, notably xs:dateTime and xs:date. Both seem to be a subset of ISO 8601.

For example, the lexical representation of xs:dateTime is

[-]CCYY-MM-DDThh:mm:ss[Z|(+|-)hh:mm]

whereas the last part represents the time zone (as offset to UTC). The Z means Zulu time which is a fancy way of meaning UTC. Two examples of date strings are:

2000-01-16Z and 1981-07-02.

xs:dateTime is formatted accordingly, just with a time component:

2001-10-26T21:32:52+02:00 and 2001-10-26T19:32:52Z.

You get the idea.

Note
Always specify an UTC offset (and thus a time zone) when working with date and time values or convert the value to UTC (passing the 'Z' flag) before handing them over to EWS. Microsoft Exchange Server internally stores all date and time values in UTC and will use subtle rules to convert them to UTC when no UTC offset is given.

This library does not interpret, parse, or in any way touch date nor date/time strings in any circumstance. The date_time class acts solely as a thin wrapper to make the signatures of public API functions more type-rich and easier to understand. date_time is implicitly convertible from std::string.

If your date or date/time strings are not formatted properly, the Exchange Server will likely give you a SOAP fault which this library transports to you as an exception of type ews::soap_fault.

Member Function Documentation

static date_time ews::date_time::from_epoch ( time_t  epoch)
inlinestatic

Constructs a xs:dateTime formatted string from given time value.

The resulting string is always formatted as:

yyyy-MM-ddThh:mm:ssZ

Parameters
epochSeconds since the Epoch (this value is always in UTC)

This function throws an exception of type ews::exception if converting to a string fails.

time_t ews::date_time::to_epoch ( ) const
inline

Converts this xs:dateTime to Seconds since the Epoch.

Returns this date-time string's corresponding seconds since the Epoch (this value is always in UTC) expressed as a value of type time_t or throws an exception of type ews::exception if this fails for some reason.


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