com php-src: Merge in changes in timelib 2016.01: ext/date/lib/interval.c ext/date/lib/parse_date.re ext/date/lib/timelib.c ext /date/lib/timelib.h
| From: | Derick Rethans | Date: | Fri, 29 Jan 2016 14:21:55 +0000 |
| Subject: | com php-src: Merge in changes in timelib 2016.01: ext/date/lib/interval.c ext/date/lib/parse_date.re ext/date/lib/timelib.c ext /date/lib/timelib.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-90805@lists.php.net to get a copy of this message | ||
Commit: 822ca45220db0b864af9dc79b94bda03a9323621
Author: Derick Rethans <github@derickrethans.nl> Fri, 29 Jan 2016 15:21:55 +0100
Parents: fa548e5ca9b275ac383cadddde0f4e6d9a806f24
Branches: PHP-5.6 PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=822ca45220db0b864af9dc79b94bda03a9323621
Log:
Merge in changes in timelib 2016.01
Changed paths:
M ext/date/lib/interval.c
M ext/date/lib/parse_date.re
M ext/date/lib/timelib.c
M ext/date/lib/timelib.h
Diff:
diff --git a/ext/date/lib/interval.c b/ext/date/lib/interval.c
index 6a3403f..9c1cc3b 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 3ff00be..3d4cf6b 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 73cdfa2...b938d9f 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 125b8b2..fe1069b 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);