1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fixed diff, again

This commit is contained in:
Derick Rethans
2022-07-15 12:19:22 +01:00
parent 37d460b64a
commit 355995735b
4 changed files with 173 additions and 127 deletions

View File

@@ -26,10 +26,37 @@
#include "timelib_private.h"
#include <math.h>
static void sort_old_to_new(timelib_time **one, timelib_time **two, timelib_rel_time *rt)
static void swap_times(timelib_time **one, timelib_time **two, timelib_rel_time *rt)
{
timelib_time *swp;
swp = *two;
*two = *one;
*one = swp;
rt->invert = 1;
}
static void swap_if_negative(timelib_rel_time *rt)
{
if (rt->y == 0 && rt->m == 0 && rt->d == 0 && rt->h == 0 && rt->i == 0 && rt->s == 0 && rt->us == 0) {
return;
}
if (rt->y >= 0 && rt->m >= 0 && rt->d >= 0 && rt->h >= 0 && rt->i >= 0 && rt->s >= 0 && rt->us >= 0) {
return;
}
rt->invert = 1 - rt->invert;
rt->y = 0 - rt->y;
rt->m = 0 - rt->m;
rt->d = 0 - rt->d;
rt->h = 0 - rt->h;
rt->i = 0 - rt->i;
rt->s = 0 - rt->s;
rt->us = 0 - rt->us;
}
static void sort_old_to_new(timelib_time **one, timelib_time **two, timelib_rel_time *rt)
{
/* Check whether date/times need to be inverted. If both times are
* TIMELIB_ZONETYPE_ID times with the same TZID, we use the y-s + us fields. */
if (
@@ -46,10 +73,7 @@ static void sort_old_to_new(timelib_time **one, timelib_time **two, timelib_rel_
((*one)->y == (*two)->y && (*one)->m == (*two)->m && (*one)->d == (*two)->d && (*one)->h == (*two)->h && (*one)->i == (*two)->i && (*one)->s > (*two)->s) ||
((*one)->y == (*two)->y && (*one)->m == (*two)->m && (*one)->d == (*two)->d && (*one)->h == (*two)->h && (*one)->i == (*two)->i && (*one)->s == (*two)->s && (*one)->us > (*two)->us)
) {
swp = *two;
*two = *one;
*one = swp;
rt->invert = 1;
swap_times(one, two, rt);
}
return;
}
@@ -59,14 +83,11 @@ static void sort_old_to_new(timelib_time **one, timelib_time **two, timelib_rel_
((*one)->sse > (*two)->sse) ||
((*one)->sse == (*two)->sse && (*one)->us > (*two)->us)
) {
swp = *two;
*two = *one;
*one = swp;
rt->invert = 1;
swap_times(one, two, rt);
}
}
timelib_rel_time *timelib_diff(timelib_time *one, timelib_time *two)
static timelib_rel_time *timelib_diff_with_tzid(timelib_time *one, timelib_time *two)
{
timelib_rel_time *rt;
timelib_sll dst_corr = 0, dst_h_corr = 0, dst_m_corr = 0;
@@ -98,7 +119,7 @@ timelib_rel_time *timelib_diff(timelib_time *one, timelib_time *two)
if (one->zone_type == TIMELIB_ZONETYPE_ID && two->zone_type == TIMELIB_ZONETYPE_ID) {
trans = timelib_get_time_zone_info(two->sse, two->tz_info);
if (trans) {
if (one->sse >= trans->transition_time + dst_corr && one->sse < trans->transition_time) {
if (one->sse < trans->transition_time && one->sse >= trans->transition_time + dst_corr) {
timelib_sll flipped = SECS_PER_HOUR + (rt->i * 60) + (rt->s);
rt->h = flipped / SECS_PER_HOUR;
rt->i = (flipped - rt->h * SECS_PER_HOUR) / 60;
@@ -160,19 +181,11 @@ timelib_rel_time *timelib_diff(timelib_time *one, timelib_time *two)
}
}
} else {
/* Then for all the others */
if (
(one->zone_type == 3 && two->zone_type == 3) ||
(one->zone_type != 3 && two->zone_type == 3 && one->z == two->z) ||
(one->zone_type == 3 && two->zone_type != 3 && one->z == two->z)
) {
rt->h -= dst_h_corr;
} else {
rt->h -= dst_h_corr + (two->dst - one->dst);
}
rt->h -= dst_h_corr;
rt->i -= dst_m_corr;
swap_if_negative(rt);
timelib_do_rel_normalize(rt->invert ? one : two, rt);
}
@@ -183,6 +196,40 @@ timelib_rel_time *timelib_diff(timelib_time *one, timelib_time *two)
return rt;
}
timelib_rel_time *timelib_diff(timelib_time *one, timelib_time *two)
{
timelib_rel_time *rt;
if (one->zone_type == TIMELIB_ZONETYPE_ID && two->zone_type == TIMELIB_ZONETYPE_ID) {
return timelib_diff_with_tzid(one, two);
}
rt = timelib_rel_time_ctor();
rt->invert = 0;
sort_old_to_new(&one, &two, rt);
rt->y = two->y - one->y;
rt->m = two->m - one->m;
rt->d = two->d - one->d;
rt->h = two->h - one->h;
if (one->zone_type != TIMELIB_ZONETYPE_ID) {
rt->h = rt->h + one->dst;
}
if (two->zone_type != TIMELIB_ZONETYPE_ID) {
rt->h = rt->h - two->dst;
}
rt->i = two->i - one->i;
rt->s = two->s - one->s - two->z + one->z;
rt->us = two->us - one->us;
rt->days = timelib_diff_days(one, two);
timelib_do_rel_normalize(rt->invert ? one : two, rt);
return rt;
}
int timelib_diff_days(timelib_time *one, timelib_time *two)
{

View File

@@ -1,4 +1,4 @@
/* Generated by re2c 0.15.3 on Fri May 20 12:52:14 2022 */
/* Generated by re2c 0.15.3 on Sun Jun 26 17:34:01 2022 */
#line 1 "ext/date/lib/parse_date.re"
/*
* The MIT License (MIT)
@@ -911,6 +911,7 @@ timelib_long timelib_parse_zone(const char **ptr, int *dst, timelib_time *t, int
offset = timelib_lookup_abbr(ptr, dst, &tz_abbr, &found);
if (found) {
t->zone_type = TIMELIB_ZONETYPE_ABBR;
t->dst = *dst;
timelib_time_tz_abbr_update(t, tz_abbr);
}
@@ -953,11 +954,11 @@ static int scan(Scanner *s, timelib_tz_get_wrapper tz_get_wrapper)
std:
s->tok = cursor;
s->len = 0;
#line 1084 "ext/date/lib/parse_date.re"
#line 1085 "ext/date/lib/parse_date.re"
#line 961 "<stdout>"
#line 962 "<stdout>"
{
YYCTYPE yych;
unsigned int yyaccept = 0;
@@ -1095,7 +1096,7 @@ yy2:
}
yy3:
YYDEBUG(3, *YYCURSOR);
#line 1818 "ext/date/lib/parse_date.re"
#line 1819 "ext/date/lib/parse_date.re"
{
int tz_not_found;
DEBUG_OUTPUT("tzcorrection | tz");
@@ -1108,7 +1109,7 @@ yy3:
TIMELIB_DEINIT;
return TIMELIB_TIMEZONE;
}
#line 1112 "<stdout>"
#line 1113 "<stdout>"
yy4:
YYDEBUG(4, *YYCURSOR);
yych = *++YYCURSOR;
@@ -1415,12 +1416,12 @@ yy11:
if (yych <= '9') goto yy1483;
yy12:
YYDEBUG(12, *YYCURSOR);
#line 1913 "ext/date/lib/parse_date.re"
#line 1914 "ext/date/lib/parse_date.re"
{
add_error(s, TIMELIB_ERR_UNEXPECTED_CHARACTER, "Unexpected character");
goto std;
}
#line 1424 "<stdout>"
#line 1425 "<stdout>"
yy13:
YYDEBUG(13, *YYCURSOR);
yych = *++YYCURSOR;
@@ -2664,11 +2665,11 @@ yy48:
if (yych <= '9') goto yy54;
yy49:
YYDEBUG(49, *YYCURSOR);
#line 1902 "ext/date/lib/parse_date.re"
#line 1903 "ext/date/lib/parse_date.re"
{
goto std;
}
#line 2672 "<stdout>"
#line 2673 "<stdout>"
yy50:
YYDEBUG(50, *YYCURSOR);
yych = *++YYCURSOR;
@@ -2677,12 +2678,12 @@ yy51:
YYDEBUG(51, *YYCURSOR);
++YYCURSOR;
YYDEBUG(52, *YYCURSOR);
#line 1907 "ext/date/lib/parse_date.re"
#line 1908 "ext/date/lib/parse_date.re"
{
s->pos = cursor; s->line++;
goto std;
}
#line 2686 "<stdout>"
#line 2687 "<stdout>"
yy53:
YYDEBUG(53, *YYCURSOR);
yych = *++YYCURSOR;
@@ -3104,7 +3105,7 @@ yy83:
if (yych == 's') goto yy85;
yy84:
YYDEBUG(84, *YYCURSOR);
#line 1886 "ext/date/lib/parse_date.re"
#line 1887 "ext/date/lib/parse_date.re"
{
timelib_ull i;
DEBUG_OUTPUT("relative");
@@ -3119,7 +3120,7 @@ yy84:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
#line 3123 "<stdout>"
#line 3124 "<stdout>"
yy85:
YYDEBUG(85, *YYCURSOR);
yych = *++YYCURSOR;
@@ -4128,7 +4129,7 @@ yy218:
}
yy219:
YYDEBUG(219, *YYCURSOR);
#line 1749 "ext/date/lib/parse_date.re"
#line 1750 "ext/date/lib/parse_date.re"
{
const timelib_relunit* relunit;
DEBUG_OUTPUT("daytext");
@@ -4145,7 +4146,7 @@ yy219:
TIMELIB_DEINIT;
return TIMELIB_WEEKDAY;
}
#line 4149 "<stdout>"
#line 4150 "<stdout>"
yy220:
YYDEBUG(220, *YYCURSOR);
yych = *++YYCURSOR;
@@ -4691,7 +4692,7 @@ yy247:
}
yy248:
YYDEBUG(248, *YYCURSOR);
#line 1808 "ext/date/lib/parse_date.re"
#line 1809 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("monthtext");
TIMELIB_INIT;
@@ -4700,7 +4701,7 @@ yy248:
TIMELIB_DEINIT;
return TIMELIB_DATE_TEXT;
}
#line 4704 "<stdout>"
#line 4705 "<stdout>"
yy249:
YYDEBUG(249, *YYCURSOR);
++YYCURSOR;
@@ -4949,7 +4950,7 @@ yy261:
goto yy267;
yy262:
YYDEBUG(262, *YYCURSOR);
#line 1554 "ext/date/lib/parse_date.re"
#line 1555 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("datetextual | datenoyear");
@@ -4962,7 +4963,7 @@ yy262:
TIMELIB_DEINIT;
return TIMELIB_DATE_TEXT;
}
#line 4966 "<stdout>"
#line 4967 "<stdout>"
yy263:
YYDEBUG(263, *YYCURSOR);
yyaccept = 6;
@@ -5089,7 +5090,7 @@ yy275:
}
yy276:
YYDEBUG(276, *YYCURSOR);
#line 1856 "ext/date/lib/parse_date.re"
#line 1857 "ext/date/lib/parse_date.re"
{
int tz_not_found;
DEBUG_OUTPUT("dateshortwithtimeshort | dateshortwithtimelong | dateshortwithtimelongtz");
@@ -5118,7 +5119,7 @@ yy276:
TIMELIB_DEINIT;
return TIMELIB_SHORTDATE_WITH_TIME;
}
#line 5122 "<stdout>"
#line 5123 "<stdout>"
yy277:
YYDEBUG(277, *YYCURSOR);
yyaccept = 7;
@@ -5416,7 +5417,7 @@ yy300:
YYDEBUG(300, *YYCURSOR);
++YYCURSOR;
YYDEBUG(301, *YYCURSOR);
#line 1832 "ext/date/lib/parse_date.re"
#line 1833 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("dateshortwithtimeshort12 | dateshortwithtimelong12");
TIMELIB_INIT;
@@ -5439,7 +5440,7 @@ yy300:
TIMELIB_DEINIT;
return TIMELIB_SHORTDATE_WITH_TIME;
}
#line 5443 "<stdout>"
#line 5444 "<stdout>"
yy302:
YYDEBUG(302, *YYCURSOR);
yych = *++YYCURSOR;
@@ -6117,7 +6118,7 @@ yy361:
YYDEBUG(362, *YYCURSOR);
++YYCURSOR;
YYDEBUG(363, *YYCURSOR);
#line 1526 "ext/date/lib/parse_date.re"
#line 1527 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("datenoday");
@@ -6130,7 +6131,7 @@ yy361:
TIMELIB_DEINIT;
return TIMELIB_DATE_NO_DAY;
}
#line 6134 "<stdout>"
#line 6135 "<stdout>"
yy364:
YYDEBUG(364, *YYCURSOR);
yych = *++YYCURSOR;
@@ -6361,7 +6362,7 @@ yy368:
if (yych <= '9') goto yy372;
yy371:
YYDEBUG(371, *YYCURSOR);
#line 1670 "ext/date/lib/parse_date.re"
#line 1671 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("pgtextshort");
@@ -6374,7 +6375,7 @@ yy371:
TIMELIB_DEINIT;
return TIMELIB_PG_TEXT;
}
#line 6378 "<stdout>"
#line 6379 "<stdout>"
yy372:
YYDEBUG(372, *YYCURSOR);
yych = *++YYCURSOR;
@@ -6956,7 +6957,7 @@ yy397:
}
yy398:
YYDEBUG(398, *YYCURSOR);
#line 1728 "ext/date/lib/parse_date.re"
#line 1729 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("ago");
TIMELIB_INIT;
@@ -6976,7 +6977,7 @@ yy398:
TIMELIB_DEINIT;
return TIMELIB_AGO;
}
#line 6980 "<stdout>"
#line 6981 "<stdout>"
yy399:
YYDEBUG(399, *YYCURSOR);
yyaccept = 5;
@@ -8765,7 +8766,7 @@ yy460:
++YYCURSOR;
yy461:
YYDEBUG(461, *YYCURSOR);
#line 1419 "ext/date/lib/parse_date.re"
#line 1420 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("iso8601date4 | iso8601date2 | iso8601dateslash | dateslash");
TIMELIB_INIT;
@@ -8776,7 +8777,7 @@ yy461:
TIMELIB_DEINIT;
return TIMELIB_ISO_DATE;
}
#line 8780 "<stdout>"
#line 8781 "<stdout>"
yy462:
YYDEBUG(462, *YYCURSOR);
yych = *++YYCURSOR;
@@ -8898,7 +8899,7 @@ yy484:
YYDEBUG(484, *YYCURSOR);
++YYCURSOR;
YYDEBUG(485, *YYCURSOR);
#line 1445 "ext/date/lib/parse_date.re"
#line 1446 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("iso8601datex");
TIMELIB_INIT;
@@ -8909,7 +8910,7 @@ yy484:
TIMELIB_DEINIT;
return TIMELIB_ISO_DATE;
}
#line 8913 "<stdout>"
#line 8914 "<stdout>"
yy486:
YYDEBUG(486, *YYCURSOR);
yyaccept = 1;
@@ -9663,7 +9664,7 @@ yy508:
}
yy509:
YYDEBUG(509, *YYCURSOR);
#line 1568 "ext/date/lib/parse_date.re"
#line 1569 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("datenoyearrev");
TIMELIB_INIT;
@@ -9674,7 +9675,7 @@ yy509:
TIMELIB_DEINIT;
return TIMELIB_DATE_TEXT;
}
#line 9678 "<stdout>"
#line 9679 "<stdout>"
yy510:
YYDEBUG(510, *YYCURSOR);
yyaccept = 9;
@@ -9815,7 +9816,7 @@ yy521:
YYDEBUG(521, *YYCURSOR);
++YYCURSOR;
YYDEBUG(522, *YYCURSOR);
#line 1272 "ext/date/lib/parse_date.re"
#line 1273 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("timetiny12 | timeshort12 | timelong12");
TIMELIB_INIT;
@@ -9831,7 +9832,7 @@ yy521:
TIMELIB_DEINIT;
return TIMELIB_TIME12;
}
#line 9835 "<stdout>"
#line 9836 "<stdout>"
yy523:
YYDEBUG(523, *YYCURSOR);
yyaccept = 10;
@@ -9844,7 +9845,7 @@ yy523:
}
yy524:
YYDEBUG(524, *YYCURSOR);
#line 1309 "ext/date/lib/parse_date.re"
#line 1310 "ext/date/lib/parse_date.re"
{
int tz_not_found;
DEBUG_OUTPUT("timetiny24 | timeshort24 | timelong24 | iso8601long");
@@ -9871,7 +9872,7 @@ yy524:
TIMELIB_DEINIT;
return TIMELIB_TIME24_WITH_ZONE;
}
#line 9875 "<stdout>"
#line 9876 "<stdout>"
yy525:
YYDEBUG(525, *YYCURSOR);
yyaccept = 10;
@@ -10184,7 +10185,7 @@ yy556:
YYDEBUG(556, *YYCURSOR);
++YYCURSOR;
YYDEBUG(557, *YYCURSOR);
#line 1289 "ext/date/lib/parse_date.re"
#line 1290 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("mssqltime");
TIMELIB_INIT;
@@ -10203,7 +10204,7 @@ yy556:
TIMELIB_DEINIT;
return TIMELIB_TIME24_WITH_ZONE;
}
#line 10207 "<stdout>"
#line 10208 "<stdout>"
yy558:
YYDEBUG(558, *YYCURSOR);
yyaccept = 10;
@@ -10309,7 +10310,7 @@ yy567:
if (yych <= '9') goto yy574;
yy568:
YYDEBUG(568, *YYCURSOR);
#line 1485 "ext/date/lib/parse_date.re"
#line 1486 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("datefull");
@@ -10323,7 +10324,7 @@ yy568:
TIMELIB_DEINIT;
return TIMELIB_DATE_FULL;
}
#line 10327 "<stdout>"
#line 10328 "<stdout>"
yy569:
YYDEBUG(569, *YYCURSOR);
yych = *++YYCURSOR;
@@ -11059,7 +11060,7 @@ yy638:
YYDEBUG(639, *YYCURSOR);
++YYCURSOR;
YYDEBUG(640, *YYCURSOR);
#line 1500 "ext/date/lib/parse_date.re"
#line 1501 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("pointed date YYYY");
TIMELIB_INIT;
@@ -11070,7 +11071,7 @@ yy638:
TIMELIB_DEINIT;
return TIMELIB_DATE_FULL_POINTED;
}
#line 11074 "<stdout>"
#line 11075 "<stdout>"
yy641:
YYDEBUG(641, *YYCURSOR);
yyaccept = 10;
@@ -11106,7 +11107,7 @@ yy644:
if (yych <= '9') goto yy638;
yy645:
YYDEBUG(645, *YYCURSOR);
#line 1512 "ext/date/lib/parse_date.re"
#line 1513 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("pointed date YY");
@@ -11119,7 +11120,7 @@ yy645:
TIMELIB_DEINIT;
return TIMELIB_DATE_FULL_POINTED;
}
#line 11123 "<stdout>"
#line 11124 "<stdout>"
yy646:
YYDEBUG(646, *YYCURSOR);
yyaccept = 10;
@@ -11760,7 +11761,7 @@ yy689:
}
yy690:
YYDEBUG(690, *YYCURSOR);
#line 1471 "ext/date/lib/parse_date.re"
#line 1472 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("gnudateshort");
@@ -11773,7 +11774,7 @@ yy690:
TIMELIB_DEINIT;
return TIMELIB_ISO_DATE;
}
#line 11777 "<stdout>"
#line 11778 "<stdout>"
yy691:
YYDEBUG(691, *YYCURSOR);
yyaccept = 12;
@@ -11879,7 +11880,7 @@ yy699:
}
yy700:
YYDEBUG(700, *YYCURSOR);
#line 1403 "ext/date/lib/parse_date.re"
#line 1404 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("americanshort | american");
@@ -11894,7 +11895,7 @@ yy700:
TIMELIB_DEINIT;
return TIMELIB_AMERICAN;
}
#line 11898 "<stdout>"
#line 11899 "<stdout>"
yy701:
YYDEBUG(701, *YYCURSOR);
yyaccept = 13;
@@ -12128,7 +12129,7 @@ yy733:
if (yych <= ':') goto yy737;
yy734:
YYDEBUG(734, *YYCURSOR);
#line 1698 "ext/date/lib/parse_date.re"
#line 1699 "ext/date/lib/parse_date.re"
{
int tz_not_found;
DEBUG_OUTPUT("clf");
@@ -12148,7 +12149,7 @@ yy734:
TIMELIB_DEINIT;
return TIMELIB_CLF;
}
#line 12152 "<stdout>"
#line 12153 "<stdout>"
yy735:
YYDEBUG(735, *YYCURSOR);
yyaccept = 14;
@@ -12768,7 +12769,7 @@ yy807:
}
yy808:
YYDEBUG(808, *YYCURSOR);
#line 1431 "ext/date/lib/parse_date.re"
#line 1432 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("iso8601date2");
@@ -12781,7 +12782,7 @@ yy808:
TIMELIB_DEINIT;
return TIMELIB_ISO_DATE;
}
#line 12785 "<stdout>"
#line 12786 "<stdout>"
yy809:
YYDEBUG(809, *YYCURSOR);
yych = *++YYCURSOR;
@@ -12820,7 +12821,7 @@ yy815:
YYDEBUG(815, *YYCURSOR);
++YYCURSOR;
YYDEBUG(816, *YYCURSOR);
#line 1684 "ext/date/lib/parse_date.re"
#line 1685 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("pgtextreverse");
@@ -12833,7 +12834,7 @@ yy815:
TIMELIB_DEINIT;
return TIMELIB_PG_TEXT;
}
#line 12837 "<stdout>"
#line 12838 "<stdout>"
yy817:
YYDEBUG(817, *YYCURSOR);
yych = *++YYCURSOR;
@@ -12998,7 +12999,7 @@ yy827:
}
yy828:
YYDEBUG(828, *YYCURSOR);
#line 1719 "ext/date/lib/parse_date.re"
#line 1720 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("year4");
TIMELIB_INIT;
@@ -13006,7 +13007,7 @@ yy828:
TIMELIB_DEINIT;
return TIMELIB_CLF;
}
#line 13010 "<stdout>"
#line 13011 "<stdout>"
yy829:
YYDEBUG(829, *YYCURSOR);
yych = *++YYCURSOR;
@@ -13211,7 +13212,7 @@ yy837:
}
yy838:
YYDEBUG(838, *YYCURSOR);
#line 1540 "ext/date/lib/parse_date.re"
#line 1541 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("datenodayrev");
@@ -13224,7 +13225,7 @@ yy838:
TIMELIB_DEINIT;
return TIMELIB_DATE_NO_DAY;
}
#line 13228 "<stdout>"
#line 13229 "<stdout>"
yy839:
YYDEBUG(839, *YYCURSOR);
yych = *++YYCURSOR;
@@ -13445,7 +13446,7 @@ yy858:
if (yych <= '7') goto yy861;
yy859:
YYDEBUG(859, *YYCURSOR);
#line 1651 "ext/date/lib/parse_date.re"
#line 1652 "ext/date/lib/parse_date.re"
{
timelib_sll w, d;
DEBUG_OUTPUT("isoweek");
@@ -13463,7 +13464,7 @@ yy859:
TIMELIB_DEINIT;
return TIMELIB_ISO_WEEK;
}
#line 13467 "<stdout>"
#line 13468 "<stdout>"
yy860:
YYDEBUG(860, *YYCURSOR);
yych = *++YYCURSOR;
@@ -13473,7 +13474,7 @@ yy861:
YYDEBUG(861, *YYCURSOR);
++YYCURSOR;
YYDEBUG(862, *YYCURSOR);
#line 1632 "ext/date/lib/parse_date.re"
#line 1633 "ext/date/lib/parse_date.re"
{
timelib_sll w, d;
DEBUG_OUTPUT("isoweekday");
@@ -13491,7 +13492,7 @@ yy861:
TIMELIB_DEINIT;
return TIMELIB_ISO_WEEK;
}
#line 13495 "<stdout>"
#line 13496 "<stdout>"
yy863:
YYDEBUG(863, *YYCURSOR);
yych = *++YYCURSOR;
@@ -13563,7 +13564,7 @@ yy865:
}
yy866:
YYDEBUG(866, *YYCURSOR);
#line 1618 "ext/date/lib/parse_date.re"
#line 1619 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("pgydotd");
@@ -13576,7 +13577,7 @@ yy866:
TIMELIB_DEINIT;
return TIMELIB_PG_YEARDAY;
}
#line 13580 "<stdout>"
#line 13581 "<stdout>"
yy867:
YYDEBUG(867, *YYCURSOR);
yych = *++YYCURSOR;
@@ -13679,7 +13680,7 @@ yy886:
++YYCURSOR;
yy887:
YYDEBUG(887, *YYCURSOR);
#line 1592 "ext/date/lib/parse_date.re"
#line 1593 "ext/date/lib/parse_date.re"
{
int tz_not_found;
DEBUG_OUTPUT("xmlrpc | xmlrpcnocolon | soap | wddx | exif");
@@ -13704,7 +13705,7 @@ yy887:
TIMELIB_DEINIT;
return TIMELIB_XMLRPC_SOAP;
}
#line 13708 "<stdout>"
#line 13709 "<stdout>"
yy888:
YYDEBUG(888, *YYCURSOR);
yych = *++YYCURSOR;
@@ -14000,7 +14001,7 @@ yy892:
}
yy893:
YYDEBUG(893, *YYCURSOR);
#line 1580 "ext/date/lib/parse_date.re"
#line 1581 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("datenocolon");
TIMELIB_INIT;
@@ -14011,7 +14012,7 @@ yy893:
TIMELIB_DEINIT;
return TIMELIB_DATE_NOCOLON;
}
#line 14015 "<stdout>"
#line 14016 "<stdout>"
yy894:
YYDEBUG(894, *YYCURSOR);
yych = *++YYCURSOR;
@@ -14933,7 +14934,7 @@ yy1017:
}
yy1018:
YYDEBUG(1018, *YYCURSOR);
#line 1457 "ext/date/lib/parse_date.re"
#line 1458 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("gnudateshorter");
@@ -14946,7 +14947,7 @@ yy1018:
TIMELIB_DEINIT;
return TIMELIB_ISO_DATE;
}
#line 14950 "<stdout>"
#line 14951 "<stdout>"
yy1019:
YYDEBUG(1019, *YYCURSOR);
yyaccept = 22;
@@ -16154,7 +16155,7 @@ yy1125:
}
yy1127:
YYDEBUG(1127, *YYCURSOR);
#line 1337 "ext/date/lib/parse_date.re"
#line 1338 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("gnunocolon");
TIMELIB_INIT;
@@ -16176,7 +16177,7 @@ yy1127:
TIMELIB_DEINIT;
return TIMELIB_GNU_NOCOLON;
}
#line 16180 "<stdout>"
#line 16181 "<stdout>"
yy1128:
YYDEBUG(1128, *YYCURSOR);
yych = *++YYCURSOR;
@@ -16276,7 +16277,7 @@ yy1134:
}
yy1135:
YYDEBUG(1135, *YYCURSOR);
#line 1383 "ext/date/lib/parse_date.re"
#line 1384 "ext/date/lib/parse_date.re"
{
int tz_not_found;
DEBUG_OUTPUT("iso8601nocolon");
@@ -16295,7 +16296,7 @@ yy1135:
TIMELIB_DEINIT;
return TIMELIB_ISO_NOCOLON;
}
#line 16299 "<stdout>"
#line 16300 "<stdout>"
yy1136:
YYDEBUG(1136, *YYCURSOR);
yyaccept = 25;
@@ -17271,7 +17272,7 @@ yy1178:
}
yy1179:
YYDEBUG(1179, *YYCURSOR);
#line 1791 "ext/date/lib/parse_date.re"
#line 1792 "ext/date/lib/parse_date.re"
{
timelib_sll i;
int behavior = 0;
@@ -17287,7 +17288,7 @@ yy1179:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
#line 17291 "<stdout>"
#line 17292 "<stdout>"
yy1180:
YYDEBUG(1180, *YYCURSOR);
++YYCURSOR;
@@ -17353,7 +17354,7 @@ yy1188:
YYDEBUG(1188, *YYCURSOR);
++YYCURSOR;
YYDEBUG(1189, *YYCURSOR);
#line 1250 "ext/date/lib/parse_date.re"
#line 1251 "ext/date/lib/parse_date.re"
{
timelib_sll i;
int behavior = 0;
@@ -17374,7 +17375,7 @@ yy1188:
TIMELIB_DEINIT;
return TIMELIB_WEEK_DAY_OF_MONTH;
}
#line 17378 "<stdout>"
#line 17379 "<stdout>"
yy1190:
YYDEBUG(1190, *YYCURSOR);
yyaccept = 26;
@@ -17514,7 +17515,7 @@ yy1205:
}
yy1206:
YYDEBUG(1206, *YYCURSOR);
#line 1767 "ext/date/lib/parse_date.re"
#line 1768 "ext/date/lib/parse_date.re"
{
timelib_sll i;
int behavior = 0;
@@ -17537,7 +17538,7 @@ yy1206:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
#line 17541 "<stdout>"
#line 17542 "<stdout>"
yy1207:
YYDEBUG(1207, *YYCURSOR);
yych = *++YYCURSOR;
@@ -20486,7 +20487,7 @@ yy1387:
}
yy1388:
YYDEBUG(1388, *YYCURSOR);
#line 1227 "ext/date/lib/parse_date.re"
#line 1228 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("backof | frontof");
TIMELIB_INIT;
@@ -20508,7 +20509,7 @@ yy1388:
TIMELIB_DEINIT;
return TIMELIB_LF_DAY_OF_MONTH;
}
#line 20512 "<stdout>"
#line 20513 "<stdout>"
yy1389:
YYDEBUG(1389, *YYCURSOR);
yyaccept = 28;
@@ -20807,7 +20808,7 @@ yy1410:
YYDEBUG(1410, *YYCURSOR);
++YYCURSOR;
YYDEBUG(1411, *YYCURSOR);
#line 1210 "ext/date/lib/parse_date.re"
#line 1211 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("firstdayof | lastdayof");
TIMELIB_INIT;
@@ -20823,7 +20824,7 @@ yy1410:
TIMELIB_DEINIT;
return TIMELIB_LF_DAY_OF_MONTH;
}
#line 20827 "<stdout>"
#line 20828 "<stdout>"
yy1412:
YYDEBUG(1412, *YYCURSOR);
yyaccept = 1;
@@ -22345,7 +22346,7 @@ yy1483:
if (yych <= '9') goto yy1483;
yy1485:
YYDEBUG(1485, *YYCURSOR);
#line 1144 "ext/date/lib/parse_date.re"
#line 1145 "ext/date/lib/parse_date.re"
{
timelib_ull i;
@@ -22370,7 +22371,7 @@ yy1485:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
#line 22374 "<stdout>"
#line 22375 "<stdout>"
yy1486:
YYDEBUG(1486, *YYCURSOR);
++YYCURSOR;
@@ -22378,7 +22379,7 @@ yy1486:
if (yych <= '9') goto yy1488;
yy1487:
YYDEBUG(1487, *YYCURSOR);
#line 1170 "ext/date/lib/parse_date.re"
#line 1171 "ext/date/lib/parse_date.re"
{
timelib_sll i;
timelib_ull us;
@@ -22417,7 +22418,7 @@ yy1487:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
#line 22421 "<stdout>"
#line 22422 "<stdout>"
yy1488:
YYDEBUG(1488, *YYCURSOR);
yych = *++YYCURSOR;
@@ -22886,7 +22887,7 @@ yy1523:
++YYCURSOR;
yy1524:
YYDEBUG(1524, *YYCURSOR);
#line 1132 "ext/date/lib/parse_date.re"
#line 1133 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("tomorrow");
TIMELIB_INIT;
@@ -22897,7 +22898,7 @@ yy1524:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
#line 22901 "<stdout>"
#line 22902 "<stdout>"
yy1525:
YYDEBUG(1525, *YYCURSOR);
yych = *++YYCURSOR;
@@ -22932,7 +22933,7 @@ yy1526:
}
yy1527:
YYDEBUG(1527, *YYCURSOR);
#line 1122 "ext/date/lib/parse_date.re"
#line 1123 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("midnight | today");
TIMELIB_INIT;
@@ -22941,7 +22942,7 @@ yy1527:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
#line 22945 "<stdout>"
#line 22946 "<stdout>"
yy1528:
YYDEBUG(1528, *YYCURSOR);
yych = *++YYCURSOR;
@@ -25036,7 +25037,7 @@ yy1611:
}
yy1612:
YYDEBUG(1612, *YYCURSOR);
#line 1101 "ext/date/lib/parse_date.re"
#line 1102 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("now");
TIMELIB_INIT;
@@ -25044,7 +25045,7 @@ yy1612:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
#line 25048 "<stdout>"
#line 25049 "<stdout>"
yy1613:
YYDEBUG(1613, *YYCURSOR);
yych = *++YYCURSOR;
@@ -25183,7 +25184,7 @@ yy1619:
}
yy1620:
YYDEBUG(1620, *YYCURSOR);
#line 1110 "ext/date/lib/parse_date.re"
#line 1111 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("noon");
TIMELIB_INIT;
@@ -25194,7 +25195,7 @@ yy1620:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
#line 25198 "<stdout>"
#line 25199 "<stdout>"
yy1621:
YYDEBUG(1621, *YYCURSOR);
yyaccept = 1;
@@ -25727,7 +25728,7 @@ yy1642:
++YYCURSOR;
yy1643:
YYDEBUG(1643, *YYCURSOR);
#line 1089 "ext/date/lib/parse_date.re"
#line 1090 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("yesterday");
TIMELIB_INIT;
@@ -25738,7 +25739,7 @@ yy1643:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
#line 25742 "<stdout>"
#line 25743 "<stdout>"
yy1644:
YYDEBUG(1644, *YYCURSOR);
yyaccept = 1;
@@ -25911,7 +25912,7 @@ yy1649:
goto yy1643;
}
}
#line 1917 "ext/date/lib/parse_date.re"
#line 1918 "ext/date/lib/parse_date.re"
}

View File

@@ -1,4 +1,4 @@
/* Generated by re2c 0.15.3 on Fri May 20 11:35:03 2022 */
/* Generated by re2c 0.15.3 on Sun Jun 26 17:34:21 2022 */
#line 1 "ext/date/lib/parse_iso_intervals.re"
/*
* The MIT License (MIT)

View File

@@ -12,7 +12,6 @@ $interval_format = 'P%dDT%hH';
/*
* Forward Transitions, diff().
*/
$end = new DateTime('2010-03-14 03:00:00 -0400');
$start = new DateTime('2010-03-14 01:59:59 -0500');
echo 'fd1 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
@@ -143,7 +142,6 @@ echo "\n";
/*
* Backward Transitions, diff().
*/
$end = new DateTime('2010-11-07 01:00:00 -0500');
$start = new DateTime('2010-11-07 01:59:59 -0400');
echo 'bd1 ' . $end->format($date_format) . ' - ' . $start->format($date_format)