16 #define IMPL_IS_DIGIT(n) ((n) >= '0' && (n) <= '9')
18 #define IMPL_SAFE_DIGIT(c, to, error) \
21 if (to < 0 || to > 9) goto error; \
24 #define IMPL_MAX_TIME_ZONE_LEN sizeof("-01:00") - 1
26 #define IMPL_MAX_DATE_SEPARATE_LEN sizeof("-2147483648-01-01") - 1
28 #define IMPL_MAX_DATE_LEN IMPL_MAX_DATE_SEPARATE_LEN + IMPL_MAX_TIME_ZONE_LEN
30 #define IMPL_MAX_TIME_SEPARATE_LEN sizeof("12:34:56.000000") - 1
32 #define IMPL_MAX_TIME_LEN IMPL_MAX_TIME_SEPARATE_LEN + IMPL_MAX_TIME_ZONE_LEN
34 #define IMPL_MAX_DATE_TIME_LEN \
35 IMPL_MAX_DATE_SEPARATE_LEN + 1 + \
36 IMPL_MAX_TIME_SEPARATE_LEN + \
37 IMPL_MAX_TIME_ZONE_LEN
41 AFW_DEFINE_STATIC_INLINE(
void)
46 memset(dateTime, 0,
sizeof(*dateTime));
49 dateTime->
date.
year = 1900 + tm->tm_year;
51 dateTime->
date.
day = tm->tm_mday;
62 AFW_DEFINE_STATIC_INLINE(
void)
67 memset(time, 0,
sizeof(*time));
79 AFW_DEFINE_STATIC_INLINE(
void)
89 "year must be between "
96 if (month < 1 || month > 12) {
98 "month must be between 1 and 12",
103 if (day < 1 || day > 31) {
105 "day must be between 1 and 31",
115 AFW_DEFINE_STATIC_INLINE(
void)
116 impl_set_time_no_time_zone(
125 if (hour < 0 || hour > 24) {
127 "hour must be between 0 and 24",
131 if (hour == 24 && minute != 0 && second != 0 && microsecond != 0) {
133 "if hour is 24, minute, second, and microsecond must be 0",
137 if (minute < 0 || minute > 59) {
139 "minute must be between 0 and 59",
143 if (second < 0 || second > 255) {
145 "second must be between 0 and 255",
149 if (microsecond < 0 || microsecond > 999999) {
151 "microsecond must be between 0 and 999999",
162 AFW_DEFINE_STATIC_INLINE(
void)
166 int tz_minutes_offset,
169 if (tz_hours_offset < -14 || tz_hours_offset > 14) {
171 "tz_hours_offset must be between -14 and 14",
175 if (tz_hours_offset == -14 || tz_hours_offset == 14) {
176 if (tz_minutes_offset != 0) {
178 "if tz_hours_offset is -14 or 14, "
179 "tz_minutes_offset must be 0",
184 if (tz_minutes_offset < -1 || tz_minutes_offset > 59) {
186 "tz_minutes_offset must be between -1 and 59",
203 int tz_minutes_offset,
212 tz_hours_offset, tz_minutes_offset,
224 int tz_minutes_offset,
233 tz_hours_offset, tz_minutes_offset,
254 int tz_minutes_offset,
261 impl_set_time_no_time_zone(
263 hour, minute, second, microsecond,
266 &dateTime->time_zone,
267 tz_hours_offset, tz_minutes_offset,
283 int tz_minutes_offset,
292 hour, minute, second, microsecond,
293 tz_hours_offset, tz_minutes_offset,
312 rv = apr_time_exp_lt(&tm, apr_time);
313 if (rv != APR_SUCCESS) {
317 impl_dateTime_tm_set(dateTime, &tm, xctx);
352 "days parameter must be between 0 and "
359 "hours parameter must be between 0 and "
366 "minutes parameter must be between 0 and "
373 "seconds parameter must be between 0 and "
380 "microseconds parameter must be between 0 and "
390 dayTimeDuration->microseconds = (
afw_int32_t)microseconds;
397 dayTimeDuration->microseconds = -(
afw_int32_t)microseconds;
418 days, hours, minutes, seconds, microseconds, xctx);
432 int tz_minutes_offset,
435 impl_set_time_no_time_zone(
437 hour, minute, second, microsecond,
441 tz_hours_offset, tz_minutes_offset,
454 int tz_minutes_offset,
462 hour, minute, second, microsecond,
463 tz_hours_offset, tz_minutes_offset,
480 "years parameter must be between 0 and "
487 "months parameter must be between 0 and "
516 years, months, xctx);
532 now = apr_time_now();
535 if (dateTime_local) {
536 rv = apr_time_exp_lt(&tm, now);
537 if (rv != APR_SUCCESS) {
541 impl_dateTime_tm_set(dateTime_local, &tm, xctx);
546 rv = apr_time_exp_gmt(&tm, now);
547 if (rv != APR_SUCCESS) {
551 impl_dateTime_tm_set(dateTime_utc, &tm, xctx);
567 now = apr_time_now();
571 rv = apr_time_exp_lt(&tm, now);
572 if (rv != APR_SUCCESS) {
576 impl_time_tm_set(time_local, &tm, xctx);
581 rv = apr_time_exp_gmt(&tm, now);
582 if (rv != APR_SUCCESS) {
586 impl_time_tm_set(time_utc, &tm, xctx);
619 afw_time_set_now_local(
626 rv = apr_time_exp_lt(&tm, apr_time_now());
627 if (rv != APR_SUCCESS) {
633 impl_time_tm_set(time, &tm, xctx);
658 afw_time_set_now_local(time, xctx);
670 result = AFW_TIME_HOURS_TO_MICROSECONDS(time->time.hour) +
671 AFW_TIME_MINUTES_TO_MICROSECONDS(time->time.minute) +
672 AFW_TIME_SECONDS_TO_MICROSECONDS(time->time.second) +
673 time->time.microsecond;
675 if (time->time_zone.minutes != -1) {
676 result -= AFW_TIME_HOURS_TO_MICROSECONDS(time->time_zone.hours) +
677 AFW_TIME_MINUTES_TO_MICROSECONDS(time->time_zone.minutes);
693 if (date->
year <= 9999 && date->
year >= -9999) {
696 if (date->
year < 0) {
700 *c++ = (char)(year / 1000) +
'0';
701 *c++ = (char)((year % 1000) / 100) +
'0';
702 *c++ = year % 100 / 10 +
'0';
703 *c++ = year % 10 +
'0';
706 len = snprintf(to, IMPL_MAX_DATE_SEPARATE_LEN,
"%d", date->
year);
707 if (len < 0 || len >= IMPL_MAX_DATE_SEPARATE_LEN) {
713 *c++ = date->
month % 100 / 10 +
'0';
714 *c++ = date->
month % 10 +
'0';
716 *c++ = date->
day % 100 / 10 +
'0';
717 *c++ = date->
day % 10 +
'0';
725 impl_set_internal_to_utf8_time(
733 *c++ = time->
hour % 100 / 10 +
'0';
734 *c++ = time->
hour % 10 +
'0';
736 *c++ = time->
minute % 100 / 10 +
'0';
737 *c++ = time->
minute % 10 +
'0';
739 *c++ = time->
second % 100 / 10 +
'0';
740 *c++ = time->
second % 10 +
'0';
747 *c++ = x / 10000 +
'0';
750 *c++ = x / 1000 +
'0';
753 *c++ = x / 100 +
'0';
768 impl_set_internal_to_utf8_time_zone(
797 *c++ = hours % 100 / 10 +
'0';
798 *c++ = hours % 10 +
'0';
800 *c++ = tz->
minutes % 100 / 10 +
'0';
809 impl_utf8_date_set_internal(
817 memset(to, 0,
sizeof(*to));
822 if (len <
sizeof(
"1-23-45") - 1)
goto error;
838 if (*s < '0' || *s >
'9')
goto error;
840 if (*s < '0' || *s >
'9')
break;
841 to->
year = to->
year * 10 + (*s -
'0');
842 if (to->
year < 0)
goto error;
844 if (is_negative) to->
year = -to->
year;
857 if (len - (s - from) <
sizeof(
"-01-10") - 1)
goto error;
860 if (*s++ !=
'-')
goto error;
863 if (*s !=
'0' && *s !=
'1')
goto error;
864 to->
month = (*s++ -
'0') * 10;
865 if (*s < '0' || *s >
'9')
goto error;
866 to->
month += (*s++ -
'0');
867 if (to->
month < 1 || to->
month > 12)
goto error;
870 if (*s++ !=
'-')
goto error;
873 if (*s < '0' || *s >
'3')
goto error;
874 to->
day = (*s++ -
'0') * 10;
875 if (*s < '0' || *s >
'9')
goto error;
876 to->
day += (*s++ -
'0');
877 if (to->
day < 1)
goto error;
883 if (to->
day <= 28)
break;
884 if (to->
day > 29)
goto error;
885 if (to->
year % 4 != 0 || (to->
year % 100 == 0 && to->
year % 400 != 0))
893 if (to->
day > 30)
goto error;
897 if (to->
day > 31)
goto error;
908 impl_set_utf8_time_to_internal(
915 memset(to, 0,
sizeof(*to));
921 if (len < 2)
goto error;
923 IMPL_SAFE_DIGIT(*s++, d1, error);
924 IMPL_SAFE_DIGIT(*s++, d2, error);
925 to->
hour = d1 * 10 + d2;
926 if (len < 3 || *s ==
'+' || *s ==
'-' || *s ==
'Z')
goto finish_up;
927 if (*s++ !=
':')
goto error;
928 IMPL_SAFE_DIGIT(*s++, d1, error);
929 IMPL_SAFE_DIGIT(*s++, d2, error);
931 to->
minute = d1 * 10 + d2;
932 if (len < 3 || *s ==
'+' || *s ==
'-' || *s ==
'Z')
goto finish_up;
933 if (*s++ !=
':')
goto error;
934 IMPL_SAFE_DIGIT(*s++, d1, error);
935 IMPL_SAFE_DIGIT(*s++, d2, error);
937 to->
second = d1 * 10 + d2;
938 if (len <= 0)
goto finish_up;
943 if (len <= 0 || !IMPL_IS_DIGIT(*s))
goto error;
946 if (len <= 0 || !IMPL_IS_DIGIT(*s))
break;
949 if (len <= 0 || !IMPL_IS_DIGIT(*s))
break;
952 if (len <= 0 || !IMPL_IS_DIGIT(*s))
break;
955 if (len <= 0 || !IMPL_IS_DIGIT(*s))
break;
958 if (len <= 0 || !IMPL_IS_DIGIT(*s))
break;
967 if (to->
hour == 24) {
987 impl_set_utf8_time_zone_to_internal(
1001 if (len <= 0)
return len;
1005 if (len != 1)
goto error;
1009 if (len < 3)
goto finish_up;
1010 if (*s ==
'+') negative =
false;
1011 else if (*s ==
'-') negative =
true;
1012 else goto finish_up;
1014 IMPL_SAFE_DIGIT(*s++, d1, error);
1015 IMPL_SAFE_DIGIT(*s++, d2, error);
1017 to->
hours = d1 * 10 + d2;
1018 if (*s !=
':')
goto finish_up;
1020 if (len < 3)
goto error;
1021 IMPL_SAFE_DIGIT(*s++, d1, error);
1022 IMPL_SAFE_DIGIT(*s++, d2, error);
1038 "(('+' | '-') hh ':' mm) | 'Z'. "
1039 "hh 00-14, mm 00-59 or 00 if hh is 14", xctx);
1051 len = impl_set_internal_to_utf8_date(&date->date, &to[0], xctx);
1052 len += impl_set_internal_to_utf8_time_zone(&date->time_zone, &to[len],
1069 len = impl_utf8_date_set_internal(s, len, &internal->date, xctx);
1070 s += utf8->len - len;
1071 len = impl_set_utf8_time_zone_to_internal(s, len, &internal->time_zone,
1087 len = impl_set_internal_to_utf8_date(&dateTime->date, &to[0], xctx);
1089 len += impl_set_internal_to_utf8_time(&dateTime->time, &to[len], xctx);
1090 len += impl_set_internal_to_utf8_time_zone(&dateTime->time_zone, &to[len],
1107 len = impl_utf8_date_set_internal(s, len, &internal->date, xctx);
1108 s += utf8->len - len;
1109 if (len-- < 1 || *s++ !=
'T')
goto error;
1111 len = impl_set_utf8_time_to_internal(s, len, &internal->time, xctx);
1113 len = impl_set_utf8_time_zone_to_internal(s, len, &internal->time_zone,
1115 if (len != 0)
goto error;
1131 sizeof(
"-P2147483648DT2147483648H2147483648M2147483648.999999S") - 1];
1138 end = &wa[
sizeof(wa)];
1141 if (dayTimeDuration->days < 0 ||
1142 dayTimeDuration->hours < 0 ||
1143 dayTimeDuration->minutes < 0 ||
1144 dayTimeDuration->seconds < 0 ||
1145 dayTimeDuration->microseconds < 0)
1147 days = -dayTimeDuration->days;
1148 hours = -dayTimeDuration->hours;
1149 minutes = -dayTimeDuration->minutes;
1150 seconds = -dayTimeDuration->seconds;
1151 microseconds = -dayTimeDuration->microseconds;
1157 days = dayTimeDuration->days;
1158 hours = dayTimeDuration->hours;
1159 minutes = dayTimeDuration->minutes;
1160 seconds = dayTimeDuration->seconds;
1161 microseconds = dayTimeDuration->microseconds;
1175 if (hours != 0 || minutes != 0 || seconds != 0 || microseconds != 0) {
1197 if (seconds != 0 || microseconds != 0) {
1205 if (microseconds != 0)
do {
1208 x = microseconds % 100000;
1211 x = microseconds % 10000;
1214 x = microseconds % 1000;
1217 x = microseconds % 100;
1220 x = microseconds % 10;
1246 memset(
internal, 0,
sizeof(*
internal));
1249 if (len < 1)
goto error;
1250 is_negative =
false;
1258 if (*s++ !=
'P')
goto error;
1261 t_encountered =
false;
1264 t_encountered =
true;
1271 if (i < 0)
goto error;
1274 if (len < 1)
goto error;
1278 if (t_encountered)
goto error;
1280 internal->days = (
afw_int32_t)((is_negative) ? -i : i);
1282 if (--len <= 0)
goto finished;
1286 if (!t_encountered) {
1287 if (*s++ !=
'T')
goto error;
1289 if (len < 1)
goto error;
1291 if (i < 0)
goto error;
1294 if (len < 1)
goto error;
1300 internal->hours = (
afw_int32_t)((is_negative) ? -i : i);
1302 if (--len <= 0)
goto finished;
1304 if (i < 0)
goto error;
1307 if (len < 1)
goto error;
1313 internal->minutes = (
afw_int32_t)((is_negative) ? -i : i);
1315 if (--len <= 0)
goto finished;
1317 if (i < 0)
goto error;
1320 if (len < 1)
goto error;
1325 internal->seconds = (
afw_int32_t)((is_negative) ? -i : i);
1331 if (len <= 0 || !IMPL_IS_DIGIT(*s))
goto error;
1333 internal->microseconds = (*s++ -
'0') * 100000;
1334 if (len <= 0 || !IMPL_IS_DIGIT(*s))
break;
1336 internal->microseconds += (*s++ -
'0') * 10000;
1337 if (len <= 0 || !IMPL_IS_DIGIT(*s))
break;
1339 internal->microseconds += (*s++ -
'0') * 1000;
1340 if (len <= 0 || !IMPL_IS_DIGIT(*s))
break;
1342 internal->microseconds += (*s++ -
'0') * 100;
1343 if (len <= 0 || !IMPL_IS_DIGIT(*s))
break;
1345 internal->microseconds += (*s++ -
'0') * 10;
1346 if (len <= 0 || !IMPL_IS_DIGIT(*s))
break;
1348 internal->microseconds += (*s++ -
'0');
1351 internal->microseconds = -
internal->microseconds;
1356 if (len != 1 || *s !=
'S')
goto error;
1375 len = impl_set_internal_to_utf8_time(&time->time, &to[0], xctx);
1376 len += impl_set_internal_to_utf8_time_zone(&time->time_zone, &to[len],
1393 len = impl_set_utf8_time_to_internal(s, len, &internal->time, xctx);
1394 s += utf8->len - len;
1395 len = impl_set_utf8_time_zone_to_internal(s, len, &internal->time_zone,
1417 end = &wa[
sizeof(wa)];
1420 if (yearMonthDuration->years < 0 ||
1421 yearMonthDuration->months < 0)
1423 years = -yearMonthDuration->years;
1424 months = -yearMonthDuration->months;
1430 years = yearMonthDuration->years;
1431 months = yearMonthDuration->months;
1469 memset(
internal, 0,
sizeof(*
internal));
1472 if (len < 1)
goto error;
1473 is_negative =
false;
1481 if (*s++ !=
'P')
goto error;
1486 if (i < 0)
goto error;
1489 if (len < 1)
goto error;
1494 internal->years = (
afw_int32_t)((is_negative) ? -i : i);
1496 if (--len <= 0)
goto finished;
1498 if (i < 0)
goto error;
1505 internal->months = (
afw_int32_t)((is_negative) ? -i : i);
1522 if (v1->time_zone.hours != v2->time_zone.hours ||
1523 v1->time_zone.minutes != v2->time_zone.minutes) {
1525 "Can't compare dates with different time zone values",
1528 result = v1->date.year - v2->date.year;
1529 if (result != 0)
goto finished;
1530 result = v1->date.month - v2->date.month;
1531 if (result != 0)
goto finished;
1532 result = v1->date.day - v2->date.day;
1535 return (result == 0) ? 0 : (result > 0) ? 1 : -1;
1547 if ((v1->time_zone.minutes == -1 && v2->time_zone.minutes != -1) ||
1548 (v1->time_zone.minutes != -1 && v2->time_zone.minutes == -1))
1551 "Can't compare dateTimes with only one value time zone",
1556 result = v1->date.year - v2->date.year;
1557 if (result != 0)
goto finished;
1558 result = v1->date.month - v2->date.month;
1559 if (result != 0)
goto finished;
1560 result = v1->date.day - v2->date.day;
1561 if (result != 0)
goto finished;
1563 if (v1->time_zone.hours != v2->time_zone.hours ||
1564 v1->time_zone.minutes != v2->time_zone.minutes) {
1565 v1hour = v1->time.hour - v1->time_zone.hours;
1566 v2hour = v2->time.hour - v2->time_zone.hours;
1567 v1minute = v1->time.minute - v1->time_zone.minutes;
1568 v2minute = v2->time.minute - v2->time_zone.minutes;
1569 result = v1hour - v2hour;
1570 if (result != 0)
goto finished;
1571 result = v1minute - v2minute;
1572 if (result != 0)
goto finished;
1576 if (result != 0)
goto finished;
1578 if (result != 0)
goto finished;
1581 if (result != 0)
goto finished;
1585 return (result == 0) ? 0 : (result > 0) ? 1 : -1;
1597 if ((v1->time_zone.minutes == -1 && v2->time_zone.minutes != -1)||
1598 (v1->time_zone.minutes != -1 && v2->time_zone.minutes == -1))
1601 "Can't compare times with only one value time zone",
1606 if (v1->time_zone.hours != v2->time_zone.hours ||
1607 v1->time_zone.minutes != v2->time_zone.minutes) {
1608 v1hour = v1->time.hour + v1->time_zone.hours;
1609 v2hour = v2->time.hour + v2->time_zone.hours;
1610 v1minute = v1->time.minute + v1->time_zone.minutes;
1611 v2minute = v2->time.minute + v2->time_zone.minutes;
1612 result = v1hour - v2hour;
1613 if (result != 0)
goto finished;
1614 result = v1minute - v2minute;
1615 if (result != 0)
goto finished;
1619 if (result != 0)
goto finished;
1621 if (result != 0)
goto finished;
1625 if (result != 0)
goto finished;
1629 return (result == 0) ? 0 : (result > 0) ? 1 : -1;
1652 return a - impl_fQuotient2(a, b) * b;
1659 return impl_fQuotient2((a - low), (high - low));
1666 return impl_modulo2((a - low), (high - low)) + low;
1675 m = impl_modulo3(month, 1, 13);
1680 if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
1698 impl_normalize_dayTimeDuration(
1703 memset(to, 0,
sizeof(*to));
1706 to->seconds = from->seconds % 60;
1708 minutes = from->minutes + (from->seconds / 60);
1709 to->minutes = minutes % 60;
1711 hours = from->hours + (minutes / 60);
1714 "dayTimeDuration limit exceeded", xctx);
1718 days = from->days + (hours / 24);
1721 "dayTimeDuration limit exceeded", xctx);
1729 impl_normalize_yearMonthDuration(
1736 memset(to, 0,
sizeof(*to));
1738 to->months = (
afw_int32_t)impl_modulo3(from->months, 1, 13);
1740 years = from->years + impl_fQuotient3(from->months, 1, 13);
1743 "yearMonthDuration limit exceeded", xctx);
1757 impl_normalize_dayTimeDuration(v1, &n1, xctx);
1758 impl_normalize_dayTimeDuration(v2, &n2, xctx);
1761 if (n1.days != n2.days)
return (n1.days > n2.days) ? 1 : -1;
1762 if (n1.hours != n2.hours)
return (n1.hours > n2.hours) ? 1 : -1;
1763 if (n1.minutes != n2.minutes)
return (n1.minutes > n2.minutes) ? 1 : -1;
1764 if (n1.seconds != n2.seconds)
return (n1.seconds > n2.seconds) ? 1 : -1;
1765 if (n1.microseconds != n2.microseconds)
1766 return (n1.microseconds > n2.microseconds) ? 1 : -1;
1779 impl_normalize_yearMonthDuration(v1, &n1, xctx);
1780 impl_normalize_yearMonthDuration(v2, &n2, xctx);
1783 if (n1.years != n2.years)
return (n1.years > n2.years) ? 1 : -1;
1784 if (n1.months != n2.months)
return (n1.months > n2.months) ? 1 : -1;
1799 year = date->date.year + yearMonthDuration->years;
1800 month = date->date.month + yearMonthDuration->months;
1802 year += impl_fQuotient3(month, 1, 13);
1803 month = impl_modulo3(month, 1, 13);
1807 "year limit exceeded", xctx);
1813 if (date->date.day > days_in_month) {
1829 year = date->date.year - yearMonthDuration->years;
1830 month = date->date.month - yearMonthDuration->months;
1832 year += impl_fQuotient3(month, 1, 13);
1833 month = impl_modulo3(month, 1, 13);
1837 "year limit exceeded", xctx);
1843 if (date->date.day > days_in_month) {
1859 year = dateTime->date.year;
1860 month = dateTime->date.month;
1862 temp = dateTime->time.microsecond + dayTimeDuration->microseconds;
1863 dateTime->time.microsecond = (
afw_uint32_t)impl_modulo2(temp, 1000000);
1864 carry = impl_fQuotient2(temp, 1000000);
1866 temp = dateTime->time.second + dayTimeDuration->seconds + carry;
1867 dateTime->time.second = (
afw_uint8_t)impl_modulo2(temp, 60);
1868 carry = impl_fQuotient2(temp, 60);
1870 temp = dateTime->time.minute + dayTimeDuration->minutes + carry;
1871 dateTime->time.minute = (
afw_uint8_t)impl_modulo2(temp, 60);
1872 carry = impl_fQuotient2(temp, 60);
1874 temp = dateTime->time.hour + dayTimeDuration->hours + carry;
1875 dateTime->time.hour = (
afw_uint8_t)impl_modulo2(temp, 24);
1876 carry = impl_fQuotient2(temp, 24);
1879 day = dateTime->date.day;
1883 else if (dateTime->date.day < 1) {
1886 day += dayTimeDuration->days + carry;
1895 if (day <= dim)
break;
1899 temp = month + carry;
1900 month = impl_modulo3(temp, 1, 13);
1901 year += impl_fQuotient3(temp, 1, 13);
1923 year = dateTime->date.year;
1924 month = dateTime->date.month;
1926 temp = dateTime->time.microsecond - dayTimeDuration->microseconds;
1927 dateTime->time.microsecond = (
afw_uint32_t)impl_modulo2(temp, 1000000);
1928 carry = impl_fQuotient2(temp, 1000000);
1930 temp = dateTime->time.second - dayTimeDuration->seconds + carry;
1931 dateTime->time.second = (
afw_uint8_t)impl_modulo2(temp, 60);
1932 carry = impl_fQuotient2(temp, 60);
1934 temp = dateTime->time.minute - dayTimeDuration->minutes + carry;
1935 dateTime->time.minute = (
afw_uint8_t)impl_modulo2(temp, 60);
1936 carry = impl_fQuotient2(temp, 60);
1938 temp = dateTime->time.hour - dayTimeDuration->hours + carry;
1939 dateTime->time.hour = (
afw_uint8_t)impl_modulo2(temp, 24);
1940 carry = impl_fQuotient2(temp, 24);
1943 day = dateTime->date.day;
1947 else if (dateTime->date.day < 1) {
1950 day = day - dayTimeDuration->days + carry;
1959 if (day <= dim)
break;
1963 temp = month + carry;
1964 month = impl_modulo3(temp, 1, 13);
1965 year += impl_fQuotient3(temp, 1, 13);
1987 year = dateTime->date.year + yearMonthDuration->years;
1988 month = dateTime->date.month + yearMonthDuration->months;
1990 year += impl_fQuotient3(month, 1, 13);
1991 month = impl_modulo3(month, 1, 13);
1995 "year limit exceeded", xctx);
2001 if (dateTime->date.day > days_in_month) {
2002 dateTime->date.day = (
afw_int8_t)days_in_month;
2017 year = dateTime->date.year - yearMonthDuration->years;
2018 month = dateTime->date.month - yearMonthDuration->months;
2020 year += impl_fQuotient3(month, 1, 13);
2021 month = impl_modulo3(month, 1, 13);
2025 "year limit exceeded", xctx);
2031 if (dateTime->date.day > days_in_month) {
2032 dateTime->date.day = (
afw_int8_t)days_in_month;
2046 len = impl_set_internal_to_utf8_date(&dateTime->date, &to[0], xctx);
2049 "afw_dateType_internal_to_generalized_time() "
2050 "can not convert to > 4 digit years",
2053 len += impl_set_internal_to_utf8_time(&dateTime->time, &to[len], xctx);
2054 len += impl_set_internal_to_utf8_time_zone(&dateTime->time_zone, &to[len],
2073 len = generalized_time->len;
2074 i = generalized_time->s;
2076 if (len <
sizeof(
"yyyymmddhhmmss") - 1)
goto error;
2099 utf8.len = o - &wa[0];
2100 len -=
sizeof(
"yyyymmddhhmmss") - 1;
2102 if (utf8.len + len > IMPL_MAX_DATE_TIME_LEN)
goto error;
AFW_DEFINE(const afw_object_t *)
#define AFW_DECLARE(type)
Declare a public afw function.
Adaptive Framework Core Internal.
void impl_set_date_no_time_zone(afw_date_no_time_zone_t *date, int year, int month, int day, afw_xctx_t *xctx)
uint8_t afw_uint8_t
8-bit unsigned integer.
apr_int32_t afw_int32_t
32-bit signed integer.
int8_t afw_int8_t
8-bit signed integer.
#define AFW_INT32_MIN
Min int32.
#define AFW_INT32_MAX
Max int32.
#define AFW_STRINGIFY(x)
Evaluate x and quote the results.
apr_uint32_t afw_uint32_t
32-bit unsigned integer.
char afw_utf8_octet_t
8 bits of utf-8 codepoint.
apr_size_t afw_size_t
size_t.
#define AFW_UINT32_MAX
Max uint32.
apr_int64_t afw_integer_t
typedef for big signed int.
#define AFW_THROW_ERROR_RV_Z(code, rv_source_id, rv, message_z, xctx)
Macro used to set error and rv in xctx and throw it.
#define AFW_THROW_ERROR_Z(code, message_z, xctx)
Macro used to set error and 0 rv in xctx and throw it.
#define afw_number_parse_integer(cursor, len, i, p, xctx)
Parse an integer using specified pool for work area.
afw_number_integer_set_u8(afw_integer_t i, afw_utf8_octet_t *s, afw_size_t len, afw_xctx_t *xctx)
Convert an integer to u8 in supplied buffer.
#define afw_pool_calloc(instance, size, xctx)
Call method calloc of interface afw_pool.
#define afw_pool_calloc_type(instance, type, xctx)
Macro to allocate cleared memory to hold type in pool.
afw_time_now_local(const afw_pool_t *p, afw_xctx_t *xctx)
Get now local time as time only in specified pool.
afw_date_create_from_parts(int year, int month, int day, int tz_hours_offset, int tz_minutes_offset, const afw_pool_t *p, afw_xctx_t *xctx)
Create afw_date_t from parts in specific pool.
afw_date_subtract_yearMonthDuration(afw_date_t *date, const afw_yearMonthDuration_t *yearMonthDuration, afw_xctx_t *xctx)
Subtract yearMonthDuration from date.
afw_dayTimeDuration_internal_to_utf8(const afw_dayTimeDuration_t *dayTimeDuration, const afw_pool_t *p, afw_xctx_t *xctx)
Convert internal dayTimeDuration to utf8 xml schema dayTimeDuration in specified pool.
afw_dateTime_set_from_parts(afw_dateTime_t *dateTime, int year, int month, int day, int hour, int minute, int second, int microsecond, int tz_hours_offset, int tz_minutes_offset, afw_xctx_t *xctx)
Set afw_dateTime_t from parts.
afw_date_add_yearMonthDuration(afw_date_t *date, const afw_yearMonthDuration_t *yearMonthDuration, afw_xctx_t *xctx)
Add yearMonthDuration to date.
afw_dayTimeDuration_create_from_parts(afw_boolean_t is_positive, afw_int32_t days, afw_int32_t hours, afw_int32_t minutes, afw_int32_t seconds, afw_int32_t microseconds, const afw_pool_t *p, afw_xctx_t *xctx)
Create afw_dayTimeDuration_t from parts in specific pool.
afw_yearMonthDuration_compare(const afw_yearMonthDuration_t *v1, const afw_yearMonthDuration_t *v2, afw_xctx_t *xctx)
compare two yearMonthDuration values.
afw_time_set_now(afw_time_t *time_local, afw_time_t *time_utc, afw_xctx_t *xctx)
Set local and/or utc time to now.
afw_date_utf8_set_internal(const afw_utf8_t *utf8, afw_date_t *internal, afw_xctx_t *xctx)
Convert utf8 xml schema date to internal and set.
afw_dayTimeDuration_compare(const afw_dayTimeDuration_t *v1, const afw_dayTimeDuration_t *v2, afw_xctx_t *xctx)
compare two dateTime values.
afw_yearMonthDuration_create_from_parts(afw_boolean_t is_positive, afw_int32_t years, afw_int32_t months, const afw_pool_t *p, afw_xctx_t *xctx)
Create afw_yearMonthDuration_t from parts in specific pool.
afw_dataType_generalized_time_set_internal(const afw_utf8_t *generalized_time, afw_dateTime_t *internal, afw_xctx_t *xctx)
Convert generalized time (see X.208) to internal and set.
afw_date_internal_to_utf8(const afw_date_t *date, const afw_pool_t *p, afw_xctx_t *xctx)
Convert internal date to utf8 xml schema date in specified pool.
afw_dateTime_now_local(const afw_pool_t *p, afw_xctx_t *xctx)
Get now local time as dateTime in specified pool.
afw_dayTimeDuration_set_from_parts(afw_dayTimeDuration_t *dayTimeDuration, afw_boolean_t is_positive, int days, int hours, int minutes, int seconds, int microseconds, afw_xctx_t *xctx)
Set afw_dayTimeDuration_t from parts.
afw_date_set_from_parts(afw_date_t *date, int year, int month, int day, int tz_hours_offset, int tz_minutes_offset, afw_xctx_t *xctx)
Set afw_date_t from parts.
afw_dateTime_internal_to_utf8(const afw_dateTime_t *dateTime, const afw_pool_t *p, afw_xctx_t *xctx)
Convert internal dateTime to utf8 xml schema dateTime in specified pool.
afw_time_to_microseconds_utc(const afw_time_t *time, afw_xctx_t *xctx)
Convert time normalize to utc to microseconds.
afw_time_now_utc(const afw_pool_t *p, afw_xctx_t *xctx)
Get now time as time only in specified pool.
const afw_dateTime_t * afw_dateTime_create_from_apr_time(apr_time_t apr_time, const afw_pool_t *p, afw_xctx_t *xctx)
Create afw_dateTime_t from apr time.
afw_time_utf8_set_internal(const afw_utf8_t *utf8, afw_time_t *internal, afw_xctx_t *xctx)
Convert utf8 xml schema dateTime to internal and set.
afw_yearMonthDuration_internal_to_utf8(const afw_yearMonthDuration_t *yearMonthDuration, const afw_pool_t *p, afw_xctx_t *xctx)
Convert internal yearMonthDuration to utf8 xml schema yearMonthDuration in specified pool.
afw_time_internal_to_utf8(const afw_time_t *time, const afw_pool_t *p, afw_xctx_t *xctx)
Convert internal time to utf8 xml schema time in specified pool.
afw_dateTime_subtract_yearMonthDuration(afw_dateTime_t *dateTime, const afw_yearMonthDuration_t *yearMonthDuration, afw_xctx_t *xctx)
Subtract yearMonthDuration from dateTime.
afw_time_create_from_parts(int hour, int minute, int second, int microsecond, int tz_hours_offset, int tz_minutes_offset, const afw_pool_t *p, afw_xctx_t *xctx)
Create afw_time_t from parts in specific pool.
afw_yearMonthDuration_set_from_parts(afw_yearMonthDuration_t *yearMonthDuration, afw_boolean_t is_positive, int years, int months, afw_xctx_t *xctx)
Set afw_yearMonthDuration_t from parts.
afw_time_set_from_parts(afw_time_t *time, int hour, int minute, int second, int microsecond, int tz_hours_offset, int tz_minutes_offset, afw_xctx_t *xctx)
Set afw_time_t from parts.
afw_date_compare(const afw_date_t *v1, const afw_date_t *v2, afw_xctx_t *xctx)
compare two date values.
void afw_dateTime_set_from_apr_time(afw_dateTime_t *dateTime, apr_time_t apr_time, afw_xctx_t *xctx)
Set afw_dateTime_t from apr_time.
afw_dateTime_subtract_dayTimeDuration(afw_dateTime_t *dateTime, const afw_dayTimeDuration_t *dayTimeDuration, afw_xctx_t *xctx)
Subtract dayTimeDuration from dateTime.
afw_dateTime_add_yearMonthDuration(afw_dateTime_t *dateTime, const afw_yearMonthDuration_t *yearMonthDuration, afw_xctx_t *xctx)
Add yearMonthDuration to dateTime.
afw_date_maximum_days_in_month(afw_integer_t year, afw_integer_t month)
Determine maximum days in a month.
afw_dateTime_compare(const afw_dateTime_t *v1, const afw_dateTime_t *v2, afw_xctx_t *xctx)
compare two dateTime values.
afw_dateTime_create_from_parts(int year, int month, int day, int hour, int minute, int second, int microsecond, int tz_hours_offset, int tz_minutes_offset, const afw_pool_t *p, afw_xctx_t *xctx)
Create afw_dateTime_t from parts in specific pool.
afw_time_compare(const afw_time_t *v1, const afw_time_t *v2, afw_xctx_t *xctx)
compare two time values.
afw_dateTime_set_now(afw_dateTime_t *dateTime_local, afw_dateTime_t *dateTime_utc, afw_xctx_t *xctx)
Set local and/or utc dateTime to now.
afw_dateTime_utf8_set_internal(const afw_utf8_t *utf8, afw_dateTime_t *internal, afw_xctx_t *xctx)
Convert utf8 xml schema dateTime to internal and set.
afw_dayTimeDuration_utf8_set_internal(const afw_utf8_t *utf8, afw_dayTimeDuration_t *internal, afw_xctx_t *xctx)
Convert utf8 xml schema dayTimeDuration to internal and set.
afw_dateType_internal_to_generalized_time(const afw_dateTime_t *dateTime, const afw_pool_t *p, afw_xctx_t *xctx)
Convert internal dateTime to generalized time (see X.208) in specified pool.
afw_dateTime_add_dayTimeDuration(afw_dateTime_t *dateTime, const afw_dayTimeDuration_t *dayTimeDuration, afw_xctx_t *xctx)
Add dayTimeDuration to dateTime.
afw_dateTime_now_utc(const afw_pool_t *p, afw_xctx_t *xctx)
Get now time as dateTime in specified pool.
afw_yearMonthDuration_utf8_set_internal(const afw_utf8_t *utf8, afw_yearMonthDuration_t *internal, afw_xctx_t *xctx)
Convert utf8 xml schema yearMonthDuration to internal and set.
#define afw_utf8_create_copy(s, len, p, xctx)
Make a utf-8 sting from chars in pool specified.
date, time, and time zone.
afw_time_no_time_zone_t time
afw_date_no_time_zone_t date
afw_time_zone_t time_zone
Interface afw_pool public struct.
afw_time_no_time_zone_t time
afw_time_zone_t time_zone
NFC normalized UTF-8 string.
Interface afw_xctx public struct.