9#include <boost/python/class.hpp>
10#include <boost/python/make_constructor.hpp>
11#include <boost/python/operators.hpp>
14#include <numpy/arrayobject.h>
15#include <numpy/arrayscalars.h>
20using boost::python::arg;
30 return self.toISO8601String() +
" ";
34 PyErr_Warn(PyExc_DeprecationWarning,
".total_nanoseconds() is deprecated. Use .totalNanoseconds() instead.");
35 return self.totalNanoseconds();
39 class_<DateAndTime>(
"DateAndTime", no_init)
41 .def(init<const std::string>((arg(
"self"), arg(
"ISO8601 string")),
"Construct from an ISO8601 string"))
42 .def(init<double, double>((arg(
"self"), arg(
"seconds"), arg(
"nanoseconds")),
43 "Construct using a number of seconds and nanoseconds (floats)since "
45 .def(init<int64_t, int64_t>((arg(
"self"), arg(
"seconds"), arg(
"nanoseconds")),
46 "Construct using a number of seconds and nanoseconds (integers) "
47 "since 1990-01-01T00:00"))
48 .def(init<int64_t>((arg(
"self"), arg(
"total_nanoseconds")),
49 "Construct a total number of nanoseconds since 1990-01-01T00:00"))
51 "Construct from numpy.datetime64")
52 .def(
"total_nanoseconds", &
total_nanoseconds, arg(
"self"),
"Since 1990-01-01T00:00")
53 .def(
"totalNanoseconds", &DateAndTime::totalNanoseconds, arg(
"self"),
"Since 1990-01-01T00:00")
54 .def(
"toISO8601String", &DateAndTime::toISO8601String, arg(
"self"),
55 "Converts the time into ISO8601Standard and returns the string")
56 .def(
"setToMinimum", &DateAndTime::setToMinimum, arg(
"self"))
58 "Convert to numpy.datetime64")
61 .def(
"__long__", &DateAndTime::totalNanoseconds, arg(
"self"))
62 .def(
"__int__", &DateAndTime::totalNanoseconds, arg(
"self"))
67 .def(self + int64_t())
68 .def(self += int64_t())
69 .def(self - int64_t())
70 .def(self -= int64_t())
75 PyErr_Warn(PyExc_DeprecationWarning,
".total_nanoseconds() is deprecated. Use .totalNanoseconds() instead.");
76 return self.total_nanoseconds();
80 class_<time_duration>(
"time_duration", no_init)
81 .def(
"hours", &time_duration::hours, arg(
"self"),
"Returns the normalized number of hours")
82 .def(
"minutes", &time_duration::minutes, arg(
"self"),
"Returns the normalized number of minutes +/-(0..59)")
83 .def(
"seconds", &time_duration::seconds, arg(
"self"),
"Returns the normalized number of seconds +/-(0..59)")
84 .def(
"total_seconds", &time_duration::total_seconds, arg(
"self"),
85 "Get the total number of seconds truncating any fractional seconds")
86 .def(
"total_milliseconds", &time_duration::total_milliseconds, arg(
"self"),
87 "Get the total number of milliseconds truncating any remaining "
89 .def(
"total_microseconds", &time_duration::total_microseconds, arg(
"self"),
90 "Get the total number of microseconds truncating any remaining "
93 "Get the total number of nanoseconds truncating any remaining "
95 .def(
"totalNanoseconds", &time_duration::total_nanoseconds, arg(
"self"),
96 "Get the total number of nanoseconds truncating any remaining "
void export_DateAndTime()
int64_t time_duration_total_nanoseconds(time_duration &self)
std::string ISO8601StringPlusSpace(const DateAndTime &self)
Circumvent a bug in IPython 1.1, which chokes on nanosecond precision datetimes.
int64_t total_nanoseconds(const DateAndTime &self)
void export_time_duration()
MANTID_PYTHONINTERFACE_CORE_DLL std::shared_ptr< Types::Core::DateAndTime > to_dateandtime(const boost::python::api::object &value)
MANTID_PYTHONINTERFACE_CORE_DLL PyObject * to_datetime64(const Types::Core::DateAndTime &dateandtime)
Convert to numpy's datetime64. This is panda's name for the function.