Class for handling dates/times, including MJD, UTC, and TAI.
More...
#include <DateTime.h>
|
| DateTime () |
| Default constructor: construct an invalid DateTime.
|
|
| DateTime (long long nsecs, Timescale scale=TAI) |
| Construct a DateTime from nanoseconds since the unix epoch.
|
|
| DateTime (double date, DateSystem system=MJD, Timescale scale=TAI) |
| Construct a DateTime from a double in the specified system and scale.
|
|
| DateTime (int year, int month, int day, int hr, int min, int sec, Timescale scale=TAI) |
| Construct a DateTime from year, month, day, etc.
|
|
| DateTime (std::string const &iso8601, Timescale scale) |
| Construct a DateTime from an ISO8601 string.
|
|
long long | nsecs (Timescale scale=TAI) const |
| Get date as nanoseconds since the unix epoch.
|
|
double | get (DateSystem system=MJD, Timescale scale=TAI) const |
| Get date as a double in a specified representation, such as MJD.
|
|
std::string | toString (Timescale scale) const |
| Get date as an ISO8601-formatted string.
|
|
struct tm | gmtime (Timescale scale) const |
| Get date as a tm struct, with truncated fractional seconds.
|
|
struct timespec | timespec (Timescale scale) const |
| Get date as a timespec struct, with time in seconds and nanoseconds.
|
|
struct timeval | timeval (Timescale scale) const |
| Get date as a timeval struct, with time in seconds and microseconds.
|
|
bool | isValid () const |
| Is this date valid?
|
|
bool | operator== (DateTime const &rhs) const |
|
std::size_t | hash_value () const noexcept |
| Return a hash of this object.
|
|
Class for handling dates/times, including MJD, UTC, and TAI.
Definition at line 64 of file DateTime.h.
◆ DateSystem
◆ Timescale
◆ DateTime() [1/5]
lsst::daf::base::DateTime::DateTime |
( |
| ) |
|
|
explicit |
◆ DateTime() [2/5]
lsst::daf::base::DateTime::DateTime |
( |
long long |
nsecs, |
|
|
Timescale |
scale = TAI |
|
) |
| |
|
explicit |
Construct a DateTime from nanoseconds since the unix epoch.
- Parameters
-
[in] | nsecs | integer nanoseconds since the unix epoch; if nsecs == DateTime.invalid_nsecs then the DateTime is invalid, regardless of scale |
[in] | scale | time scale of input (TAI, TT or UTC, default TAI). |
- Exceptions
-
Definition at line 309 of file DateTime.cc.
◆ DateTime() [3/5]
Construct a DateTime from a double in the specified system and scale.
- Parameters
-
[in] | date | specified date |
[in] | system | time system of input (JD, MJD, or [Julian] EPOCH) |
[in] | scale | time scale of input (TAI, TT or UTC, default TAI). |
- Exceptions
-
Definition at line 311 of file DateTime.cc.
◆ DateTime() [4/5]
lsst::daf::base::DateTime::DateTime |
( |
int |
year, |
|
|
int |
month, |
|
|
int |
day, |
|
|
int |
hr, |
|
|
int |
min, |
|
|
int |
sec, |
|
|
Timescale |
scale = TAI |
|
) |
| |
Construct a DateTime from year, month, day, etc.
(tm struct fields)
- Parameters
-
[in] | year | year; must be in the range [1902, 2261], inclusive. |
[in] | month | month number, where January = 1 |
[in] | day | day of the month (1 to 31). |
[in] | hr | hour (0 to 23) |
[in] | min | minute (0 to 59) |
[in] | sec | integer seconds (0 to 60) |
[in] | scale | time scale of input (TAI, TT or UTC, default TAI). |
- Exceptions
-
Definition at line 328 of file DateTime.cc.
◆ DateTime() [5/5]
Construct a DateTime from an ISO8601 string.
Accepts a restricted subset of ISO8601: yyyy-mm-ddThh:mm:ss.nnnnnnnnnZ where:
- the final Z is required for UTC and prohibited for TAI or TT
- the - and : separators are optional
- the decimal point and fractional seconds are optional
- the decimal point may be a comma
- Parameters
-
[in] | iso8601 | ISO8601 string representation of date and time |
[in] | scale | time scale of input (TAI, TT or UTC, default TAI). |
- Exceptions
-
Definition at line 386 of file DateTime.cc.
◆ get()
Get date as a double in a specified representation, such as MJD.
- Returns
- the date in the required system, for the requested scale
- Parameters
-
[in] | system | desired time system (JD, MJD, or [Julian] EPOCH) |
[in] | scale | desired time scale (TAI, TT or UTC) |
- Exceptions
-
Definition at line 430 of file DateTime.cc.
◆ gmtime()
struct tm lsst::daf::base::DateTime::gmtime |
( |
Timescale |
scale | ) |
const |
Get date as a tm struct, with truncated fractional seconds.
- Parameters
-
[in] | scale | desired time scale (TAI, TT or UTC) |
- Returns
- date as a tm struct
- Exceptions
-
Definition at line 466 of file DateTime.cc.
◆ hash_value()
std::size_t lsst::daf::base::DateTime::hash_value |
( |
| ) |
const |
|
noexcept |
Return a hash of this object.
Definition at line 516 of file DateTime.cc.
◆ initializeLeapSeconds()
void lsst::daf::base::DateTime::initializeLeapSeconds |
( |
std::string const & |
leapString | ) |
|
|
static |
◆ isValid()
bool lsst::daf::base::DateTime::isValid |
( |
| ) |
const |
|
inline |
◆ now()
DateTime lsst::daf::base::DateTime::now |
( |
void |
| ) |
|
|
static |
Return current time as a DateTime.
Assumes the system clock keeps UTC, as almost all computers do.
Definition at line 518 of file DateTime.cc.
◆ nsecs()
long long lsst::daf::base::DateTime::nsecs |
( |
Timescale |
scale = TAI | ) |
const |
Get date as nanoseconds since the unix epoch.
- Note
- If the DateTime is invalid then the returned value is DateTime.invalid_nsecs, regardless of scale.
- Parameters
-
[in] | scale | desired time scale (TAI, TT or UTC) |
- Returns
- the date as nanoseconds since the unix epoch in the specified time scale
- Exceptions
-
Definition at line 448 of file DateTime.cc.
◆ operator==()
bool lsst::daf::base::DateTime::operator== |
( |
DateTime const & |
rhs | ) |
const |
◆ timespec()
struct timespec lsst::daf::base::DateTime::timespec |
( |
Timescale |
scale | ) |
const |
Get date as a timespec struct, with time in seconds and nanoseconds.
- Parameters
-
[in] | scale | Desired time scale (TAI, TT or UTC) |
- Returns
- date as a timespec struct
- Exceptions
-
Definition at line 482 of file DateTime.cc.
◆ timeval()
struct timeval lsst::daf::base::DateTime::timeval |
( |
Timescale |
scale | ) |
const |
Get date as a timeval struct, with time in seconds and microseconds.
- Parameters
-
[in] | scale | desired time scale (TAI, TT or UTC) |
- Returns
- date as a timeval struct
- Exceptions
-
Definition at line 491 of file DateTime.cc.
◆ toString()
Get date as an ISO8601-formatted string.
The returned format is: yyyy-mm-ddThh:mm:ss.sssssssssZ where the final Z is only present if scale is UTC
- Parameters
-
[in] | scale | Desired time scale (TAI, TT or UTC). |
- Exceptions
-
Definition at line 500 of file DateTime.cc.
◆ boost::serialization::access
friend class boost::serialization::access |
|
friend |
◆ invalid_nsecs
The documentation for this class was generated from the following files: