/*! \file */
+#include <ctype.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdlib.h>
}
/* Every duration starts with 'P' */
- P = strchr(str, 'P');
+ P = strpbrk(str, "Pp");
if (P == NULL) {
return (ISC_R_BADNUMBER);
}
/* Record the time indicator. */
- T = strchr(str, 'T');
+ T = strpbrk(str, "Tt");
/* Record years. */
- X = strchr(str, 'Y');
+ X = strpbrk(str, "Yy");
if (X != NULL) {
duration->parts[0] = atoi(str+1);
str = X;
}
/* Record months. */
- X = strchr(str, 'M');
+ X = strpbrk(str, "Mm");
/*
* M could be months or minutes. This is months if there is no time
}
/* Record days. */
- X = strchr(str, 'D');
+ X = strpbrk(str, "Dd");
if (X != NULL) {
duration->parts[3] = atoi(str+1);
str = X;
}
/* Record hours. */
- X = strchr(str, 'H');
+ X = strpbrk(str, "Hh");
if (X != NULL && T != NULL) {
duration->parts[4] = atoi(str+1);
str = X;
}
/* Record minutes. */
- X = strrchr(str, 'M');
+ X = strpbrk(str, "Mm");
/*
* M could be months or minutes. This is minutes if there is a time
}
/* Record seconds. */
- X = strchr(str, 'S');
+ X = strpbrk(str, "Ss");
if (X != NULL && T != NULL) {
duration->parts[6] = atoi(str+1);
str = X;
}
/* Or is the duration configured in weeks? */
- W = strchr(buf, 'W');
+ W = strpbrk(buf, "Ww");
if (W != NULL) {
if (not_weeks) {
/* Mix of weeks and other indicators is not allowed */
duration.unlimited = false;
- if (TOKEN_STRING(pctx)[0] == 'P') {
+ if (toupper(TOKEN_STRING(pctx)[0]) == 'P') {
result = duration_fromtext(&pctx->token.value.as_textregion,
&duration);
duration.iso8601 = true;
duration_conf_t durations[] = {
{ .string = "PT0S", .time = 0 },
{ .string = "PT42S", .time = 42 },
- { .string = "PT10M", .time = 600 },
- { .string = "PT10M4S", .time = 604 },
- { .string = "PT2H", .time = 7200 },
- { .string = "PT2H3S", .time = 7203 },
- { .string = "PT2H1M3S", .time = 7263 },
- { .string = "P7D", .time = 604800 },
- { .string = "P7DT2H", .time = 612000 },
+ { .string = "PT10m", .time = 600 },
+ { .string = "PT10m4S", .time = 604 },
+ { .string = "pT2H", .time = 7200 },
+ { .string = "Pt2H3S", .time = 7203 },
+ { .string = "PT2h1m3s", .time = 7263 },
+ { .string = "p7d", .time = 604800 },
+ { .string = "P7DT2h", .time = 612000 },
{ .string = "P2W", .time = 1209600 },
{ .string = "P3M", .time = 8035200 },
{ .string = "P3MT10M", .time = 8035800 },
- { .string = "P5Y", .time = 157680000 },
+ { .string = "p5y", .time = 157680000 },
{ .string = "P5YT2H", .time = 157687200 },
{ .string = "P1Y1M1DT1H1M1S", .time = 34304461 },
{ .string = "0", .time = 0 },
{ .string = "30", .time = 30 },
{ .string = "42s", .time = 42 },
{ .string = "10m", .time = 600 },
- { .string = "2h", .time = 7200 },
+ { .string = "2H", .time = 7200 },
{ .string = "7d", .time = 604800 },
{ .string = "2w", .time = 1209600 },
};