rt->i += dst_m_corr;
}
- rt->days = abs(floor((one->sse - two->sse - (dst_h_corr * 3600) - (dst_m_corr * 60)) / 86400));
+ rt->days = fabs(floor((one->sse - two->sse - (dst_h_corr * 3600) - (dst_m_corr * 60)) / 86400));
timelib_do_rel_normalize(rt->invert ? one : two, rt);
{ \
add_pbf_error(s, "Unexpected data found.", string, begin); \
}
+#define TIMELIB_CHECK_SIGNED_NUMBER \
+ if (strchr("-0123456789", *ptr) == NULL) \
+ { \
+ add_pbf_error(s, "Unexpected data found.", string, begin); \
+ }
static void timelib_time_reset_fields(timelib_time *time)
{
timelib_eat_spaces((char **) &ptr);
break;
case 'U': /* epoch seconds */
- TIMELIB_CHECK_NUMBER;
+ TIMELIB_CHECK_SIGNED_NUMBER;
TIMELIB_HAVE_RELATIVE();
tmp = timelib_get_unsigned_nr((char **) &ptr, 24);
s->time->y = 1970;
return tmp;
}
+int timelib_time_compare(timelib_time *t1, timelib_time *t2)
+{
+ if (t1->sse == t2->sse) {
+ if (t1->f == t2->f) {
+ return 0;
+ }
+
+ if (t1->sse < 0) {
+ return (t1->f < t2->f) ? 1 : -1;
+ } else {
+ return (t1->f < t2->f) ? -1 : 1;
+ }
+ }
+
+ return (t1->sse < t2->sse) ? -1 : 1;
+}
+
timelib_rel_time* timelib_rel_time_clone(timelib_rel_time *rel)
{
timelib_rel_time *tmp = timelib_rel_time_ctor();
void timelib_time_set_option(timelib_time* tm, int option, void* option_value);
void timelib_time_dtor(timelib_time* t);
timelib_time* timelib_time_clone(timelib_time* orig);
+int timelib_time_compare(timelib_time *t1, timelib_time *t2);
timelib_time_offset* timelib_time_offset_ctor(void);
void timelib_time_offset_dtor(timelib_time_offset* t);