2019-12-15 01:25:00 +08:00
|
|
|
/*
|
|
|
|
* _TimeDelta.cpp
|
|
|
|
*
|
|
|
|
* Copyright (C) 2019 hikyuu.org
|
|
|
|
*
|
|
|
|
* Created on: 2019-12-14
|
|
|
|
* Author: fasiondog
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <boost/python.hpp>
|
|
|
|
#include <hikyuu/serialization/TimeDelta_serialization.h>
|
|
|
|
#include "pickle_support.h"
|
|
|
|
|
|
|
|
using namespace boost::python;
|
|
|
|
using namespace hku;
|
|
|
|
|
2019-12-24 02:15:37 +08:00
|
|
|
double (TimeDelta::*TimeDelta_div_1)(TimeDelta) const = &TimeDelta::operator/;
|
|
|
|
TimeDelta (TimeDelta::*TimeDelta_div_2)(double) const = &TimeDelta::operator/;
|
|
|
|
|
2019-12-15 01:25:00 +08:00
|
|
|
void export_TimeDelta() {
|
|
|
|
class_<TimeDelta>("TimeDelta", init<>())
|
2019-12-22 03:02:35 +08:00
|
|
|
.def(init<int64_t, int64_t, int64_t, int64_t, int64_t, int64_t>(
|
2019-12-24 02:15:37 +08:00
|
|
|
(arg("days") = 0, arg("hours") = 0, arg("minutes") = 0, arg("seconds") = 0, arg("milliseconds") = 0,
|
|
|
|
arg("microseconds") = 0)))
|
2019-12-22 03:02:35 +08:00
|
|
|
//.def(self_ns::str(self))
|
|
|
|
.def("__str__", &TimeDelta::str)
|
|
|
|
.def("__repr__", &TimeDelta::repr)
|
2019-12-18 02:04:54 +08:00
|
|
|
.add_property("days", &TimeDelta::days)
|
|
|
|
.add_property("hours", &TimeDelta::hours)
|
|
|
|
.add_property("minutes", &TimeDelta::minutes)
|
|
|
|
.add_property("seconds", &TimeDelta::seconds)
|
|
|
|
.add_property("milliseconds", &TimeDelta::milliseconds)
|
|
|
|
.add_property("microseconds", &TimeDelta::microseconds)
|
|
|
|
.add_property("ticks", &TimeDelta::ticks)
|
2019-12-23 02:18:04 +08:00
|
|
|
.def("isNegative", &TimeDelta::isNegative)
|
2019-12-18 02:04:54 +08:00
|
|
|
.def("max", &TimeDelta::max)
|
2019-12-19 02:32:06 +08:00
|
|
|
.staticmethod("max")
|
2019-12-18 02:04:54 +08:00
|
|
|
.def("min", &TimeDelta::min)
|
2019-12-19 02:32:06 +08:00
|
|
|
.staticmethod("min")
|
2019-12-18 02:04:54 +08:00
|
|
|
.def("resolution", &TimeDelta::resolution)
|
2019-12-19 02:32:06 +08:00
|
|
|
.staticmethod("resolution")
|
2019-12-21 03:01:33 +08:00
|
|
|
.def("maxTicks", &TimeDelta::maxTicks)
|
|
|
|
.staticmethod("maxTicks")
|
|
|
|
.def("minTicks", &TimeDelta::minTicks)
|
|
|
|
.staticmethod("minTicks")
|
|
|
|
.def("fromTicks", &TimeDelta::fromTicks)
|
|
|
|
.staticmethod("fromTicks")
|
2019-12-19 02:32:06 +08:00
|
|
|
|
|
|
|
.def("__eq__", &TimeDelta::operator==)
|
|
|
|
.def("__ne__", &TimeDelta::operator!=)
|
|
|
|
.def("__gt__", &TimeDelta::operator>)
|
|
|
|
.def("__lt__", &TimeDelta::operator<)
|
|
|
|
.def("__ge__", &TimeDelta::operator>=)
|
|
|
|
.def("__le__", &TimeDelta::operator>=)
|
|
|
|
|
2019-12-24 02:15:37 +08:00
|
|
|
.def("__abs__", &TimeDelta::abs)
|
2019-12-19 02:32:06 +08:00
|
|
|
.def("__add__", &TimeDelta::operator+)
|
|
|
|
.def("__sub__", &TimeDelta::operator-)
|
2019-12-24 02:15:37 +08:00
|
|
|
.def("__mul__", &TimeDelta::operator*)
|
|
|
|
.def("__rmul__", &TimeDelta::operator*)
|
|
|
|
.def("__truediv__", TimeDelta_div_1)
|
|
|
|
.def("__truediv__", TimeDelta_div_2)
|
|
|
|
.def("__mod__", &TimeDelta::operator%)
|
2019-12-18 02:04:54 +08:00
|
|
|
|
2019-12-15 01:25:00 +08:00
|
|
|
#if HKU_PYTHON_SUPPORT_PICKLE
|
|
|
|
.def_pickle(normal_pickle_suite<TimeDelta>())
|
|
|
|
#endif
|
|
|
|
;
|
2019-12-22 03:02:35 +08:00
|
|
|
|
|
|
|
def("Days", Days);
|
|
|
|
def("Hours", Hours);
|
|
|
|
def("Minutes", Minutes);
|
|
|
|
def("Seconds", Seconds);
|
|
|
|
def("Milliseconds", Milliseconds);
|
|
|
|
def("Microseconds", Microseconds);
|
2019-12-15 01:25:00 +08:00
|
|
|
}
|