summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorDerick Rethans <github@derickrethans.nl>2016-01-29 15:21:55 +0100
committerDerick Rethans <github@derickrethans.nl>2016-01-29 15:21:55 +0100
commit822ca45220db0b864af9dc79b94bda03a9323621 (patch)
tree422df83a291c6f34cbc035a694a6d07a92a9a268 /ext
parentfa548e5ca9b275ac383cadddde0f4e6d9a806f24 (diff)
downloadphp-git-822ca45220db0b864af9dc79b94bda03a9323621.tar.gz
Merge in changes in timelib 2016.01
Diffstat (limited to 'ext')
-rw-r--r--ext/date/lib/interval.c2
-rw-r--r--ext/date/lib/parse_date.re7
-rw-r--r--ext/date/lib/timelib.c17
-rw-r--r--ext/date/lib/timelib.h1
4 files changed, 25 insertions, 2 deletions
diff --git a/ext/date/lib/interval.c b/ext/date/lib/interval.c
index 6a3403fc3e..9c1cc3b273 100644
--- a/ext/date/lib/interval.c
+++ b/ext/date/lib/interval.c
@@ -70,7 +70,7 @@ timelib_rel_time *timelib_diff(timelib_time *one, timelib_time *two)
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);
diff --git a/ext/date/lib/parse_date.re b/ext/date/lib/parse_date.re
index 3ff00bec3e..3d4cf6bb61 100644
--- a/ext/date/lib/parse_date.re
+++ b/ext/date/lib/parse_date.re
@@ -1812,6 +1812,11 @@ timelib_time* timelib_strtotime(char *s, size_t len, struct timelib_error_contai
{ \
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)
{
@@ -2016,7 +2021,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, size_t len,
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;
diff --git a/ext/date/lib/timelib.c b/ext/date/lib/timelib.c
index 73cdfa2d85..b938d9f998 100644
--- a/ext/date/lib/timelib.c
+++ b/ext/date/lib/timelib.c
@@ -65,6 +65,23 @@ timelib_time* timelib_time_clone(timelib_time *orig)
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();
diff --git a/ext/date/lib/timelib.h b/ext/date/lib/timelib.h
index 125b8b21ad..fe1069bdde 100644
--- a/ext/date/lib/timelib.h
+++ b/ext/date/lib/timelib.h
@@ -138,6 +138,7 @@ timelib_time* timelib_time_ctor(void);
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);