OpenStudio:utilities
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | Static Public Member Functions | List of all members
openstudio::DateTime Class Reference

#include <DateTime.hpp>

Public Member Functions

Date date () const
 getter to date member More...
 
 DateTime ()
 default constructor, UTC time is assumed More...
 
 DateTime (const Date &date)
 constructor from Date, UTC time is assumed More...
 
 DateTime (const Date &date, const Time &timeFromDate)
 constructor from Date and Time, UTC time is assumed More...
 
 DateTime (const Date &date, const Time &timeFromDate, double utcOffset)
 constructor from Date and Time and UTC Offset More...
 
 DateTime (const DateTime &other)
 copy constructor More...
 
 DateTime (const std::string &string)
 constructor from simple string format, UTC time is assumed More...
 
 DateTime (tm t_tm)
 from system tm struct More...
 
bool operator!= (const DateTime &other) const
 non-equality operator More...
 
DateTime operator+ (const Time &time) const
 addition operator More...
 
DateTimeoperator+= (const Time &time)
 assignment by addition operator More...
 
DateTime operator- (const Time &time) const
 difference operator More...
 
Time operator- (const DateTime &dateTime) const
 time duration More...
 
Time operator- (const Date &date) const
 time duration More...
 
DateTimeoperator-= (const Time &time)
 assignment by difference operator More...
 
bool operator< (const DateTime &rhs) const
 less than operator More...
 
bool operator<= (const DateTime &rhs) const
 less than equals operator More...
 
DateTimeoperator= (const DateTime &other)
 assignment operator More...
 
bool operator== (const DateTime &other) const
 equality operator More...
 
bool operator> (const DateTime &rhs) const
 greater than operator More...
 
bool operator>= (const DateTime &rhs) const
 greater than equals operator More...
 
Time time () const
 getter to time member More...
 
time_t toEpoch () const
 convert to epoch time_t in UTC time More...
 
std::string toISO8601 () const
 convert to ISO 8601 string More...
 
std::string toString () const
 convert to simple string format in UTC More...
 
std::string toXsdDateTime () const
 convert to xsd:dateTime format More...
 
double utcOffset () const
 UTC offset in hours, local time = UTC time + UTC offset. More...
 

Static Public Member Functions

static DateTime fromEpoch (const std::time_t &time)
 construct from epoch time_t in UTC More...
 
static boost::optional< DateTimefromISO8601 (const std::string &str)
 construct from ISO 8601 string More...
 
static boost::optional< DateTimefromXsdDateTime (const std::string &str)
 construct from xsd:dateTime string More...
 
static double localOffsetUTC ()
 get the current UTC offset More...
 
static openstudio::LogChannel logChannel ()
 
static DateTime now ()
 get the local time now More...
 
static DateTime nowUTC ()
 get the UTC time now More...
 

Detailed Description

DateTime is an absolute unit of time, resolution to the second date is a valid Date time is normalized to 0 <= time < 24 hrs.

Constructor & Destructor Documentation

openstudio::DateTime::DateTime ( )

default constructor, UTC time is assumed

openstudio::DateTime::DateTime ( const Date date)

constructor from Date, UTC time is assumed

openstudio::DateTime::DateTime ( const Date date,
const Time timeFromDate 
)

constructor from Date and Time, UTC time is assumed

openstudio::DateTime::DateTime ( const Date date,
const Time timeFromDate,
double  utcOffset 
)

constructor from Date and Time and UTC Offset

openstudio::DateTime::DateTime ( const DateTime other)

copy constructor

openstudio::DateTime::DateTime ( const std::string &  string)

constructor from simple string format, UTC time is assumed

openstudio::DateTime::DateTime ( tm  t_tm)

from system tm struct

Member Function Documentation

Date openstudio::DateTime::date ( ) const

getter to date member

static DateTime openstudio::DateTime::fromEpoch ( const std::time_t &  time)
static

construct from epoch time_t in UTC

static boost::optional<DateTime> openstudio::DateTime::fromISO8601 ( const std::string &  str)
static

construct from ISO 8601 string

static boost::optional<DateTime> openstudio::DateTime::fromXsdDateTime ( const std::string &  str)
static

construct from xsd:dateTime string

static double openstudio::DateTime::localOffsetUTC ( )
static

get the current UTC offset

static openstudio::LogChannel openstudio::DateTime::logChannel ( )
inlinestatic
static DateTime openstudio::DateTime::now ( )
static

get the local time now

static DateTime openstudio::DateTime::nowUTC ( )
static

get the UTC time now

bool openstudio::DateTime::operator!= ( const DateTime other) const

non-equality operator

DateTime openstudio::DateTime::operator+ ( const Time time) const

addition operator

DateTime& openstudio::DateTime::operator+= ( const Time time)

assignment by addition operator

DateTime openstudio::DateTime::operator- ( const Time time) const

difference operator

Time openstudio::DateTime::operator- ( const DateTime dateTime) const

time duration

Time openstudio::DateTime::operator- ( const Date date) const

time duration

DateTime& openstudio::DateTime::operator-= ( const Time time)

assignment by difference operator

bool openstudio::DateTime::operator< ( const DateTime rhs) const

less than operator

bool openstudio::DateTime::operator<= ( const DateTime rhs) const

less than equals operator

DateTime& openstudio::DateTime::operator= ( const DateTime other)

assignment operator

bool openstudio::DateTime::operator== ( const DateTime other) const

equality operator

bool openstudio::DateTime::operator> ( const DateTime rhs) const

greater than operator

bool openstudio::DateTime::operator>= ( const DateTime rhs) const

greater than equals operator

Time openstudio::DateTime::time ( ) const

getter to time member

time_t openstudio::DateTime::toEpoch ( ) const

convert to epoch time_t in UTC time

std::string openstudio::DateTime::toISO8601 ( ) const

convert to ISO 8601 string

std::string openstudio::DateTime::toString ( ) const

convert to simple string format in UTC

std::string openstudio::DateTime::toXsdDateTime ( ) const

convert to xsd:dateTime format

double openstudio::DateTime::utcOffset ( ) const

UTC offset in hours, local time = UTC time + UTC offset.