RStudio Launcher Plugin SDK  1.1.3
A software development kit for creating plugins that work the the RStudio Launcher.
Public Member Functions | Static Public Member Functions | List of all members
rstudio::launcher_plugins::system::DateTime Class Referencefinal

Class which represents a date and time in UTC. More...

#include <DateTime.hpp>

Public Member Functions

 DateTime ()
 Constructor. More...
 
 DateTime (const DateTime &in_other)
 Copy constructor. More...
 
 DateTime (DateTime &&in_other) noexcept
 Move constructor. More...
 
 DateTime (std::time_t &in_time) noexcept
 Constructor. More...
 
DateTimeoperator= (const DateTime &in_other)
 Assignment operator. More...
 
DateTimeoperator= (DateTime &&in_other) noexcept
 Move operator. More...
 
TimeDuration operator- (const DateTime &in_other) const
 Subtracts two DateTimes to produce an TimeDuration. More...
 
DateTime operator- (const TimeDuration &in_intervalTime) const
 Subtracts the given TimeDuration from a copy of this DateTime. More...
 
DateTimeoperator-= (const TimeDuration &in_intervalTime)
 Subtracts the given TimeDuration from this DateTime. More...
 
DateTime operator+ (const TimeDuration &in_intervalTime) const
 Adds the given TimeDuration to a copy of this DateTime. More...
 
DateTimeoperator+= (const TimeDuration &in_intervalTime)
 Adds the given TimeDuration to this DateTime. More...
 
bool operator== (const DateTime &in_other) const
 Equality operator. More...
 
bool operator!= (const DateTime &in_other) const
 Inequality operator. More...
 
bool operator< (const DateTime &in_other) const
 Less than operator. More...
 
bool operator<= (const DateTime &in_other) const
 Less than operator. More...
 
bool operator> (const DateTime &in_other) const
 Less than operator. More...
 
bool operator>= (const DateTime &in_other) const
 Less than operator. More...
 
std::string toString () const
 Converts this DateTime to an ISO 8601 time string. More...
 
std::string toString (const char *in_format) const
 Converts this DateTime to a string representation defined by the provided format. More...
 
std::string toString (const std::string &in_format) const
 Converts this DateTime to a string representation defined by the provided format. More...
 

Static Public Member Functions

static Error fromString (const std::string &in_timeStr, DateTime &out_dateTime)
 Constructs a DateTime by calling FromString and passing the default ISO 8601 string reperesentation. String must be in UTC time. More...
 
static Error fromString (const std::string &in_timeStr, const std::string &in_format, DateTime &out_dateTime)
 Constructs a DateTime from a valid time format string representation. The string must be in UTC time. More...
 

Detailed Description

Class which represents a date and time in UTC.

Constructor & Destructor Documentation

◆ DateTime() [1/4]

rstudio::launcher_plugins::system::DateTime::DateTime ( )

Constructor.

Creates a date time which represents the time at which it was created.

◆ DateTime() [2/4]

rstudio::launcher_plugins::system::DateTime::DateTime ( const DateTime in_other)

Copy constructor.

Parameters
in_otherThe DateTime to copied into this.

◆ DateTime() [3/4]

rstudio::launcher_plugins::system::DateTime::DateTime ( DateTime &&  in_other)
noexcept

Move constructor.

Parameters
in_otherThe DateTime to moved into this.

◆ DateTime() [4/4]

rstudio::launcher_plugins::system::DateTime::DateTime ( std::time_t &  in_time)
noexcept

Constructor.

Parameters
in_timeThe time to copy into DateTime.

Member Function Documentation

◆ fromString() [1/2]

static Error rstudio::launcher_plugins::system::DateTime::fromString ( const std::string &  in_timeStr,
const std::string &  in_format,
DateTime out_dateTime 
)
static

Constructs a DateTime from a valid time format string representation. The string must be in UTC time.

Valid formats use the boost date_time flags here: https://www.boost.org/doc/libs/1_60_0/doc/html/date_time/date_time_io.html

Parameters
in_timeStrThe string representation of the DateTime to construct.
in_formatDesired time format.
out_dateTimeThe newly constructed DateTime, if no error occurs.
Returns
Success if in_timeStr is a valid representation of a date and time according to the provided format; Error otherwise.

◆ fromString() [2/2]

static Error rstudio::launcher_plugins::system::DateTime::fromString ( const std::string &  in_timeStr,
DateTime out_dateTime 
)
static

Constructs a DateTime by calling FromString and passing the default ISO 8601 string reperesentation. String must be in UTC time.

Default format: "%Y-%m-%dT%H:%M:%S%F%ZP" e.g. "2020-03-05T14:33:15.008765Z" e.g. "1995-10-31T02:06:22+8:00" (fractional seconds are 0) e.g. "1988-12-25T23:23:23.054321MST-06" e.g. "1972-04-18T00:01:51PST-08PDT+01,M4.1.0/02:00,M10.5.0/02:00" (Full Posix Time Zone String)

Parameters
in_timeStrThe string representation of the DateTime to construct.
out_dateTimeThe newly constructed DateTime, if no error occurs.
Returns
Success if in_timeStr is a valid ISO 8601 representation of a date and time; Error otherwise.

◆ operator!=()

bool rstudio::launcher_plugins::system::DateTime::operator!= ( const DateTime in_other) const

Inequality operator.

Parameters
in_otherThe DateTime to compare against this.
Returns
True if this DateTime and in_other represent the different times; false otherwise.

◆ operator+()

DateTime rstudio::launcher_plugins::system::DateTime::operator+ ( const TimeDuration in_intervalTime) const

Adds the given TimeDuration to a copy of this DateTime.

Parameters
in_intervalTimeThe interval time to add to this DateTime.
Returns
The new DateTime, which is this value of DateTime plus the specified TimeDuration.

◆ operator+=()

DateTime& rstudio::launcher_plugins::system::DateTime::operator+= ( const TimeDuration in_intervalTime)

Adds the given TimeDuration to this DateTime.

Parameters
in_intervalTimeThe interval time to add to this DateTime.
Returns
A reference to this DateTime.

◆ operator-() [1/2]

TimeDuration rstudio::launcher_plugins::system::DateTime::operator- ( const DateTime in_other) const

Subtracts two DateTimes to produce an TimeDuration.

Parameters
in_otherThe date time to subtract from this.
Returns
An interval time representing the difference between this DateTime and in_other.

◆ operator-() [2/2]

DateTime rstudio::launcher_plugins::system::DateTime::operator- ( const TimeDuration in_intervalTime) const

Subtracts the given TimeDuration from a copy of this DateTime.

Parameters
in_intervalTimeThe interval time to subtract from this DateTime.
Returns
A reference to this DateTime.

◆ operator-=()

DateTime& rstudio::launcher_plugins::system::DateTime::operator-= ( const TimeDuration in_intervalTime)

Subtracts the given TimeDuration from this DateTime.

Parameters
in_intervalTimeThe interval time to subtract from this DateTime.
Returns
The new DateTime, which is this value of DateTime minus the specified TimeDuration.

◆ operator<()

bool rstudio::launcher_plugins::system::DateTime::operator< ( const DateTime in_other) const

Less than operator.

Parameters
in_otherThe DateTime to compare against this.
Returns
True if this DateTime is an earlier time than in_other; false otherwise.

◆ operator<=()

bool rstudio::launcher_plugins::system::DateTime::operator<= ( const DateTime in_other) const

Less than operator.

Parameters
in_otherThe DateTime to compare against this.
Returns
True if this DateTime is an earlier time or the same time as in_other; false otherwise.

◆ operator=() [1/2]

DateTime& rstudio::launcher_plugins::system::DateTime::operator= ( const DateTime in_other)

Assignment operator.

*

Parameters
in_otherThe DateTime to assign to this.
Returns
A reference to this DateTime.

◆ operator=() [2/2]

DateTime& rstudio::launcher_plugins::system::DateTime::operator= ( DateTime &&  in_other)
noexcept

Move operator.

Parameters
in_otherThe DateTime to move to this.
Returns
A reference to this DateTime.

◆ operator==()

bool rstudio::launcher_plugins::system::DateTime::operator== ( const DateTime in_other) const

Equality operator.

Parameters
in_otherThe DateTime to compare against this.
Returns
True if this DateTime and in_other represent the exact same moment in time; false otherwise.

◆ operator>()

bool rstudio::launcher_plugins::system::DateTime::operator> ( const DateTime in_other) const

Less than operator.

Parameters
in_otherThe DateTime to compare against this.
Returns
True if this DateTime is a later time than in_other; false otherwise.

◆ operator>=()

bool rstudio::launcher_plugins::system::DateTime::operator>= ( const DateTime in_other) const

Less than operator.

Parameters
in_otherThe DateTime to compare against this.
Returns
True if this DateTime is the same time or a later time than in_other; false otherwise.

◆ toString() [1/3]

std::string rstudio::launcher_plugins::system::DateTime::toString ( ) const

Converts this DateTime to an ISO 8601 time string.

Returns
This DateTime as an ISO 8601 string representation.

◆ toString() [2/3]

std::string rstudio::launcher_plugins::system::DateTime::toString ( const char *  in_format) const

Converts this DateTime to a string representation defined by the provided format.

Parameters
in_formatThe time format string, as documented in the 'Date-Time Support' section of the 'Advanced Features' chapter of the RStudio Launcher Plugin SDK Developer's Guide.
Returns
This DateTime, as a string with the specified format.

◆ toString() [3/3]

std::string rstudio::launcher_plugins::system::DateTime::toString ( const std::string &  in_format) const

Converts this DateTime to a string representation defined by the provided format.

Parameters
in_formatThe time format string, as documented in the 'Date-Time Support' section of the 'Advanced Features' chapter of the RStudio Launcher Plugin SDK Developer's Guide.
Returns
This DateTime, as a string with the specified format.

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