LSST Applications g0b6bd0c080+a72a5dd7e6,g1182afd7b4+2a019aa3bb,g17e5ecfddb+2b8207f7de,g1d67935e3f+06cf436103,g38293774b4+ac198e9f13,g396055baef+6a2097e274,g3b44f30a73+6611e0205b,g480783c3b1+98f8679e14,g48ccf36440+89c08d0516,g4b93dc025c+98f8679e14,g5c4744a4d9+a302e8c7f0,g613e996a0d+e1c447f2e0,g6c8d09e9e7+25247a063c,g7271f0639c+98f8679e14,g7a9cd813b8+124095ede6,g9d27549199+a302e8c7f0,ga1cf026fa3+ac198e9f13,ga32aa97882+7403ac30ac,ga786bb30fb+7a139211af,gaa63f70f4e+9994eb9896,gabf319e997+ade567573c,gba47b54d5d+94dc90c3ea,gbec6a3398f+06cf436103,gc6308e37c7+07dd123edb,gc655b1545f+ade567573c,gcc9029db3c+ab229f5caf,gd01420fc67+06cf436103,gd877ba84e5+06cf436103,gdb4cecd868+6f279b5b48,ge2d134c3d5+cc4dbb2e3f,ge448b5faa6+86d1ceac1d,gecc7e12556+98f8679e14,gf3ee170dca+25247a063c,gf4ac96e456+ade567573c,gf9f5ea5b4d+ac198e9f13,gff490e6085+8c2580be5c,w.2022.27
LSST Data Management Base Package
dateTime.cc
Go to the documentation of this file.
1#include "pybind11/pybind11.h"
2
4
5namespace py = pybind11;
6using namespace pybind11::literals;
7
8namespace lsst {
9namespace daf {
10namespace base {
11
12PYBIND11_MODULE(dateTime, mod) {
13 py::class_<DateTime> cls(mod, "DateTime");
14
15 py::enum_<DateTime::Timescale>(cls, "Timescale")
16 .value("TAI", DateTime::Timescale::TAI)
17 .value("UTC", DateTime::Timescale::UTC)
18 .value("TT", DateTime::Timescale::TT)
19 .export_values();
20
21 py::enum_<DateTime::DateSystem>(cls, "DateSystem")
22 .value("JD", DateTime::DateSystem::JD)
23 .value("MJD", DateTime::DateSystem::MJD)
24 .value("EPOCH", DateTime::DateSystem::EPOCH)
25 .export_values();
26
27 cls.def(py::init<>())
28 .def_readonly_static("invalid_nsecs", &DateTime::invalid_nsecs)
29 .def(py::init<long long, DateTime::Timescale>(), "nsecs"_a, "scale"_a = DateTime::Timescale::TAI)
30 .def(py::init<double, DateTime::DateSystem, DateTime::Timescale>(), "date"_a,
31 "system"_a = DateTime::DateSystem::MJD, "scale"_a = DateTime::Timescale::TAI)
32 .def(py::init<int, int, int, int, int, int, DateTime::Timescale>())
33 .def(py::init<const std::string &, DateTime::Timescale>())
34 .def("nsecs", &DateTime::nsecs, "scale"_a = DateTime::Timescale::TAI)
35 .def("get", &DateTime::get, "system"_a = DateTime::DateSystem::MJD,
36 "scale"_a = DateTime::Timescale::TAI)
37 .def("toString", &DateTime::toString)
38 .def("gmtime", &DateTime::gmtime)
39 .def("timespec", &DateTime::timespec)
40 .def("timeval", &DateTime::timeval)
41 .def("isValid", &DateTime::isValid)
42 .def_static("now", &DateTime::now)
43 .def_static("initializeLeapSeconds", &DateTime::initializeLeapSeconds)
44 .def("__eq__", [](DateTime const &self, DateTime const &other) { return self == other; },
45 py::is_operator());
46}
47
48} // base
49} // daf
50} // lsst
Interface for DateTime class.
Class for handling dates/times, including MJD, UTC, and TAI.
Definition: DateTime.h:64
std::string toString(Timescale scale) const
Get date as an ISO8601-formatted string.
Definition: DateTime.cc:500
bool isValid() const
Is this date valid?
Definition: DateTime.h:203
struct timespec timespec(Timescale scale) const
Get date as a timespec struct, with time in seconds and nanoseconds.
Definition: DateTime.cc:482
static DateTime now(void)
Return current time as a DateTime.
Definition: DateTime.cc:518
double get(DateSystem system=MJD, Timescale scale=TAI) const
Get date as a double in a specified representation, such as MJD.
Definition: DateTime.cc:430
struct timeval timeval(Timescale scale) const
Get date as a timeval struct, with time in seconds and microseconds.
Definition: DateTime.cc:491
struct tm gmtime(Timescale scale) const
Get date as a tm struct, with truncated fractional seconds.
Definition: DateTime.cc:466
static void initializeLeapSeconds(std::string const &leapString)
Initialize the leap second table from USNO.
Definition: DateTime.cc:528
constexpr static long long invalid_nsecs
Definition: DateTime.h:75
long long nsecs(Timescale scale=TAI) const
Get date as nanoseconds since the unix epoch.
Definition: DateTime.cc:448
PYBIND11_MODULE(dateTime, mod)
Definition: dateTime.cc:12
A base class for image defects.