OpenStudio:utilities
Loading...
Searching...
No Matches
openstudio::DateTime Class Reference

#include <DateTime.hpp>

Public Member Functions

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

Static Public Member Functions

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

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

◆ DateTime() [1/7]

openstudio::DateTime::DateTime ( )

default constructor, UTC time is assumed

◆ DateTime() [2/7]

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

constructor from Date, UTC time is assumed

◆ DateTime() [3/7]

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

constructor from Date and Time, UTC time is assumed

◆ DateTime() [4/7]

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

constructor from Date and Time and UTC Offset

◆ DateTime() [5/7]

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

copy constructor

◆ DateTime() [6/7]

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

constructor from simple string format, UTC time is assumed

◆ DateTime() [7/7]

openstudio::DateTime::DateTime ( tm t_tm)

from system tm struct

Member Function Documentation

◆ date()

Date openstudio::DateTime::date ( ) const

getter to date member

◆ fromEpoch()

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

construct from epoch time_t in UTC

◆ fromISO8601()

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

construct from ISO 8601 string

◆ fromXsdDateTime()

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

construct from xsd:dateTime string

◆ localOffsetUTC()

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

get the current UTC offset

◆ logChannel()

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

◆ now()

static DateTime openstudio::DateTime::now ( )
static

get the local time now

◆ nowUTC()

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

get the UTC time now

◆ operator!=()

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

non-equality operator

◆ operator+()

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

addition operator

◆ operator+=()

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

assignment by addition operator

◆ operator-() [1/3]

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

time duration

◆ operator-() [2/3]

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

time duration

◆ operator-() [3/3]

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

difference operator

◆ operator-=()

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

assignment by difference operator

◆ operator<()

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

less than operator

◆ operator<=()

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

less than equals operator

◆ operator=()

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

assignment operator

◆ operator==()

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

equality operator

◆ operator>()

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

greater than operator

◆ operator>=()

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

greater than equals operator

◆ time()

Time openstudio::DateTime::time ( ) const

getter to time member

◆ toEpoch()

time_t openstudio::DateTime::toEpoch ( ) const

convert to epoch time_t in UTC time

◆ toISO8601()

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

convert to ISO 8601 string

◆ toString()

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

convert to simple string format in UTC

◆ toXsdDateTime()

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

convert to xsd:dateTime format

◆ utcOffset()

double openstudio::DateTime::utcOffset ( ) const

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