bool DateInterval::setInterval(const String& date_interval) { timelib_rel_time *di = nullptr; timelib_error_container *errors = nullptr; #ifdef TIMELIB_HAVE_INTERVAL timelib_time *start = nullptr, *end = nullptr; int r = 0; timelib_strtointerval((char*)date_interval.data(), date_interval.size(), &start, &end, &di, &r, &errors); #else throw_not_implemented("timelib too old"); #endif int error_count = errors->error_count; DateTime::setLastErrors(errors); if (error_count > 0) { timelib_rel_time_dtor(di); return false; } else { #ifdef TIMELIB_HAVE_INTERVAL if (UNLIKELY(!di && start && end)) { timelib_update_ts(start, nullptr); timelib_update_ts(end, nullptr); di = timelib_diff(start, end); } #endif m_di = DateIntervalPtr(di, dateinterval_deleter()); return true; } }
void c_DateInterval::t___construct(CStrRef interval_spec) { INSTANCE_METHOD_INJECTION_BUILTIN(DateInterval, DateInterval::__construct); timelib_time *b = NULL, *e = NULL; timelib_rel_time *relTime = NULL; int r = 0; timelib_error_container *errors; timelib_strtointerval((char*)interval_spec.data(), interval_spec.size(), &b, &e, &relTime, &r, &errors); int errors1 = errors->error_count; timelib_error_container_dtor(errors); if (errors1 > 0) { timelib_rel_time_dtor(relTime); raise_error("Unknown or bad format (%s)", interval_spec.c_str()); } else { rel_time_to_interval(relTime, this); timelib_rel_time_dtor(relTime); } }
bool DateInterval::setInterval(CStrRef date_interval) { timelib_rel_time *di = NULL; timelib_error_container *errors = NULL; #ifdef TIMELIB_HAVE_INTERVAL timelib_time *start = NULL, *end = NULL; int r = 0; timelib_strtointerval((char*)date_interval.data(), date_interval.size(), &start, &end, &di, &r, &errors); #else throw NotImplementedException("timelib too old"); #endif int error_count = errors->error_count; DateTime::setLastErrors(errors); if (error_count > 0) { timelib_rel_time_dtor(di); return false; } else { m_di = DateIntervalPtr(di, dateinterval_deleter()); return true; } }