From e6a0e8623547a2d3a0cfa2a64d68b49254960636 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 16 Feb 2005 05:52:04 +0000 Subject: (export_datetime): Exposed "parse_date" function. --- datetime.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'datetime.cc') diff --git a/datetime.cc b/datetime.cc index 18e67501..685939aa 100644 --- a/datetime.cc +++ b/datetime.cc @@ -400,6 +400,22 @@ std::time_t interval_getitem(interval_t& interval, int i) return last_moment; } +std::time_t py_parse_date(const char * date_str) +{ + std::time_t temp; + if (parse_date(date_str, &temp)) + return temp; + return 0; +} + +std::time_t py_parse_date_yr(const char * date_str, const int year) +{ + std::time_t temp; + if (parse_date(date_str, &temp, year)) + return temp; + return 0; +} + void export_datetime() { class_< interval_t > @@ -418,6 +434,9 @@ void export_datetime() .def("increment", &interval_t::increment) ; + + def("parse_date", py_parse_date); + def("parse_date", py_parse_date_yr); } #endif // USE_BOOST_PYTHON -- cgit v1.2.3