isce3 0.25.0
Loading...
Searching...
No Matches
isce3::core::DateTime Class Reference

Data structure to store date time to nano-sec precision. More...

#include <DateTime.h>

Public Member Functions

 DateTime ()
 Default constructor.
 
 DateTime (double ord)
 Constructor using ordinal.
 
 DateTime (int yy, int mm, int dd)
 Constructor using year, month, day of month.
 
 DateTime (int yy, int mm, int dd, int hh, int mn, int ss)
 Constructor using date, hours, mins and integer seconds.
 
 DateTime (int yy, int mm, int dd, int hh, int mn, double ss)
 Constructor using date, hours, mins, and floating point seconds.
 
 DateTime (int yy, int mm, int dd, int hh, int mn, int ss, double ff)
 Constructor using date, hours, mins, integer secs and fractional secs.
 
 DateTime (const DateTime &ts)
 Copy constructor.
 
 DateTime (const std::string &)
 Construct from a string representation in ISO-8601 format Throw exception 'InvalidArgument' for bad format, Supports both separators "T" and " ".
 
 operator std::string () const
 
bool operator< (const DateTime &ts) const
 
bool operator> (const DateTime &ts) const
 
bool operator<= (const DateTime &ts) const
 
bool operator>= (const DateTime &ts) const
 
bool operator== (const DateTime &ts) const
 
bool operator!= (const DateTime &ts) const
 
DateTimeoperator= (const DateTime &ts)
 
DateTimeoperator+= (const TimeDelta &ts)
 
DateTimeoperator+= (const double &s)
 
DateTimeoperator-= (const TimeDelta &ts)
 
DateTimeoperator-= (const double &s)
 
DateTime operator+ (const TimeDelta &ts) const
 
DateTime operator+ (const double &s) const
 
DateTime operator- (const TimeDelta &ts) const
 
DateTime operator- (const double &s) const
 
TimeDelta operator- (const DateTime &ts) const
 
bool isClose (const DateTime &ts) const
 Check whether two DateTimes are equivalent to within TOL_SECONDS.
 
bool isClose (const DateTime &ts, const TimeDelta &errtol) const
 Check whether two DateTimes are equivalent to within the specified error tolerance.
 
int dayOfYear () const
 Return day of year.
 
double secondsOfDay () const
 Return seconds of day.
 
int dayOfWeek () const
 Return day of week.
 
double ordinal () const
 Return ordinal - time since GPS time origin.
 
double secondsSinceEpoch () const
 Return ordinal - time since GPS time origin.
 
double secondsSinceEpoch (const DateTime &) const
 Return time elapsed since given DateTime epoch.
 
void secondsSinceEpoch (double)
 Return time elapsed since given ordinal epoch.
 
std::string isoformat () const
 Return date formatted as ISO-8601 string.
 
void strptime (std::string)
 Parse a given string in ISO-8601 format String can be date only "YYYY-MM-DD" or datetime w/o fraction "yyyy-mm-ddTHH:MM:SS" or w/ fraction "yyyy-mm-ddTHH:MM:SS.f" both separator "T" and white space are supported.
 

Static Public Member Functions

static bool isIsoFormat (const std::string &datetime_str)
 Check if a format is supported iso8601.
 

Public Attributes

int year
 
int months
 
int days
 
int hours
 
int minutes
 
int seconds
 
double frac
 

Detailed Description

Data structure to store date time to nano-sec precision.

Constructor & Destructor Documentation

◆ DateTime() [1/2]

isce3::core::DateTime::DateTime ( )
inline

Default constructor.

Initialize to origin of GPS time 1970-01-01T00:00:00.0

◆ DateTime() [2/2]

isce3::core::DateTime::DateTime ( const std::string & datestr)
explicit

Construct from a string representation in ISO-8601 format Throw exception 'InvalidArgument' for bad format, Supports both separators "T" and " ".

E.g, string can be date only "YYYY-MM-DD" or datetime w/o fraction "yyyy-mm-ddTHH:MM:SS" or w/ fraction "yyyy-mm-ddTHH:MM:SS.f".

Exceptions
InvalidArgument

Member Function Documentation

◆ isIsoFormat()

bool isce3::core::DateTime::isIsoFormat ( const std::string & datetime_str)
static

Check if a format is supported iso8601.

Parameters
[in]datetime_str: date or date-time string String can be date only "YYYY-MM-DD" or datetime w/o fraction "yyyy-mm-ddTHH:MM:SS" or w/ fraction "yyyy-mm-ddTHH:MM:SS.f" both separator "T" and white space are supported.
Returns
bool

◆ strptime()

void isce3::core::DateTime::strptime ( std::string datetime_str)

Parse a given string in ISO-8601 format String can be date only "YYYY-MM-DD" or datetime w/o fraction "yyyy-mm-ddTHH:MM:SS" or w/ fraction "yyyy-mm-ddTHH:MM:SS.f" both separator "T" and white space are supported.

Exceptions
InvalidArgumentfor wrong format

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

Generated for ISCE3.0 by doxygen 1.13.2.