LSSTApplications
10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
|
Class for handling dates/times, including MJD, UTC, and TAI. More...
#include <DateTime.h>
Public Types | |
enum | Timescale { TAI, UTC, TT } |
enum | DateSystem { JD, MJD, EPOCH } |
Public Member Functions | |
DateTime (long long nsecs=0LL, Timescale scale=TAI) | |
DateTime (double date, DateSystem system=MJD, Timescale scale=TAI) | |
DateTime (int year, int month, int day, int hr, int min, int sec, Timescale scale=TAI) | |
DateTime (std::string const &iso8601) | |
long long | nsecs (Timescale scale=TAI) const |
double | get (DateSystem system=MJD, Timescale scale=TAI) const |
std::string | toString (void) const |
struct tm | gmtime (void) const |
struct timespec | timespec (void) const |
struct timeval | timeval (void) const |
bool | operator== (DateTime const &rhs) const |
Static Public Member Functions | |
static DateTime | now (void) |
static void | initializeLeapSeconds (std::string const &leapString) |
Private Member Functions | |
double | _getMjd (Timescale scale) const |
double | _getJd (Timescale scale) const |
double | _getEpoch (Timescale scale) const |
void | setNsecsFromMjd (double mjd, Timescale scale) |
a function to convert MJD to interal nsecs More... | |
void | setNsecsFromJd (double jd, Timescale scale) |
a function to convert JD to internal nsecs More... | |
void | setNsecsFromEpoch (double epoch, Timescale scale) |
a function to convert epoch to internal nsecs More... | |
template<class Archive > | |
void | serialize (Archive ar, int const version) |
Private Attributes | |
long long | _nsecs |
Nanoseconds since Unix epoch. More... | |
Friends | |
class | boost::serialization::access |
Class for handling dates/times, including MJD, UTC, and TAI.
Definition at line 58 of file DateTime.h.
Enumerator | |
---|---|
JD | |
MJD | |
EPOCH |
Definition at line 61 of file DateTime.h.
Enumerator | |
---|---|
TAI | |
UTC | |
TT |
Definition at line 60 of file DateTime.h.
Constructor.
[in] | nsecs | Number of nanoseconds since the epoch. |
[in] | scale | Timescale of input (TAI or UTC, default TAI). |
Definition at line 291 of file DateTime.cc.
|
explicit |
Constructor.
[in] | date | Date. |
[in] | system | The requested date system (JD, MJD, or Julian epoch) |
[in] | scale | Timescale of input (TAI or UTC, default TAI). |
Definition at line 304 of file DateTime.cc.
lsst::daf::base::DateTime::DateTime | ( | int | year, |
int | month, | ||
int | day, | ||
int | hr, | ||
int | min, | ||
int | sec, | ||
Timescale | scale = TAI |
||
) |
Constructor.
[in] | year | Year number. |
[in] | month | Month number (Jan = 1). |
[in] | day | Day number (1 to 31). |
[in] | hr | Hour number (0 to 23). |
[in] | min | Minute number (0 to 59). |
[in] | sec | Second number (0 to 60). |
[in] | scale | Timescale of input (TAI or UTC, default TAI). |
Definition at line 332 of file DateTime.cc.
|
explicit |
Constructor. Accepts a restricted subset of ISO8601: yyyy-mm-ddThh:mm:ss.nnnnnnnnnZ where the - and : separators are optional, the fractional seconds are also optional, and the decimal point may be a comma.
[in] | iso8601 | ISO8601 representation of date and time. Must be UTC. |
Definition at line 382 of file DateTime.cc.
|
private |
Convert to Julian Epoch.
[in] | scale | Desired timescale (TAI or UTC, default TAI). |
Definition at line 482 of file DateTime.cc.
|
private |
Convert to Julian Day.
[in] | scale | Desired timescale (TAI or UTC, default TAI). |
Definition at line 474 of file DateTime.cc.
|
private |
Convert to Modified Julian Day.
[in] | scale | Desired timescale (TAI or UTC, default TAI). |
Definition at line 456 of file DateTime.cc.
double lsst::daf::base::DateTime::get | ( | DateSystem | system = MJD , |
Timescale | scale = TAI |
||
) | const |
Generic Accessor
[in] | system | The type of date requested (JD, MJD, or EPOCH) |
[in] | scale | The time scale (UTC, or TAI) |
Definition at line 419 of file DateTime.cc.
struct tm lsst::daf::base::DateTime::gmtime | ( | void | ) | const |
Convert to struct tm. Truncate fractional seconds.
Definition at line 492 of file DateTime.cc.
|
static |
Initialize leap second table.
leapString | Leap second table from USNO as a single multiline string. |
Definition at line 568 of file DateTime.cc.
|
static |
Return current time as a DateTime.
Definition at line 554 of file DateTime.cc.
Accessor.
Definition at line 441 of file DateTime.cc.
bool lsst::daf::base::DateTime::operator== | ( | DateTime const & | rhs | ) | const |
Equality operator.
Definition at line 547 of file DateTime.cc.
|
inlineprivate |
Serialize DateTime to/from a Boost archive.
[in,out] | ar | Archive to access. |
[in] | version | Version of class serializer. |
Definition at line 98 of file DateTime.h.
|
private |
a function to convert epoch to internal nsecs
[in] | epoch | The Julian epoch |
[in] | scale | The time scale (TAI, or UTC) |
Definition at line 281 of file DateTime.cc.
|
private |
a function to convert JD to internal nsecs
[in] | jd | The Julian Day |
[in] | scale | The time scale (TAI, or UTC) |
Definition at line 272 of file DateTime.cc.
|
private |
a function to convert MJD to interal nsecs
[in] | mjd | The Modified Julian Day |
[in] | scale | The time scale (TAI, or UTC) |
Definition at line 246 of file DateTime.cc.
struct timespec lsst::daf::base::DateTime::timespec | ( | void | ) | const |
Convert to struct timespec.
Definition at line 511 of file DateTime.cc.
struct timeval lsst::daf::base::DateTime::timeval | ( | void | ) | const |
Convert time to struct timeval.
Definition at line 522 of file DateTime.cc.
std::string lsst::daf::base::DateTime::toString | ( | void | ) | const |
Accessor.
Definition at line 533 of file DateTime.cc.
|
friend |
Definition at line 93 of file DateTime.h.
|
private |
Nanoseconds since Unix epoch.
Definition at line 83 of file DateTime.h.