Lines Matching refs:parser
39 iso8601_date_parse_number(struct iso8601_date_parser *parser,
44 if (parser->cur >= parser->end || !i_isdigit(parser->cur[0]))
47 *number_r = parser->cur[0] - '0';
48 parser->cur++;
51 if (parser->cur >= parser->end || !i_isdigit(parser->cur[0]))
53 *number_r = ((*number_r) * 10) + parser->cur[0] - '0';
54 parser->cur++;
60 iso8601_date_parse_secfrac(struct iso8601_date_parser *parser)
68 if (parser->cur >= parser->end || parser->cur[0] != '.')
70 parser->cur++;
73 if (parser->cur >= parser->end || !i_isdigit(parser->cur[0]))
75 parser->cur++;
78 while (parser->cur < parser->end && i_isdigit(parser->cur[0]))
79 parser->cur++;
83 static int is08601_date_parse_time_offset(struct iso8601_date_parser *parser)
93 if (parser->cur >= parser->end)
97 switch (parser->cur[0]) {
102 parser->cur++;
105 if (iso8601_date_parse_number(parser, 2, &tz_hour) <= 0)
111 if (parser->cur >= parser->end || parser->cur[0] != ':')
113 parser->cur++;
116 if (iso8601_date_parse_number(parser, 2, &tz_min) <= 0)
123 parser->cur++;
129 parser->timezone_offset = tz_sign*(tz_hour*60 + tz_min);
133 static int is08601_date_parse_full_time(struct iso8601_date_parser *parser)
144 if (iso8601_date_parse_number(parser, 2, &parser->tm.tm_hour) <= 0)
148 if (parser->cur >= parser->end || parser->cur[0] != ':')
150 parser->cur++;
153 if (iso8601_date_parse_number(parser, 2, &parser->tm.tm_min) <= 0)
157 if (parser->cur >= parser->end || parser->cur[0] != ':')
159 parser->cur++;
162 if (iso8601_date_parse_number(parser, 2, &parser->tm.tm_sec) <= 0)
166 if (iso8601_date_parse_secfrac(parser) < 0)
170 if (is08601_date_parse_time_offset(parser) <= 0)
175 static int is08601_date_parse_full_date(struct iso8601_date_parser *parser)
185 if (iso8601_date_parse_number(parser, 4, &parser->tm.tm_year) <= 0)
187 if (parser->tm.tm_year < 1900)
189 parser->tm.tm_year -= 1900;
192 if (parser->cur >= parser->end || parser->cur[0] != '-')
194 parser->cur++;
197 if (iso8601_date_parse_number(parser, 2, &parser->tm.tm_mon) <= 0)
199 parser->tm.tm_mon -= 1;
202 if (parser->cur >= parser->end || parser->cur[0] != '-')
204 parser->cur++;
207 if (iso8601_date_parse_number(parser, 2, &parser->tm.tm_mday) <= 0)
212 static int iso8601_date_parse_date_time(struct iso8601_date_parser *parser)
217 if (is08601_date_parse_full_date(parser) <= 0)
221 if (parser->cur >= parser->end ||
222 (parser->cur[0] != 'T' && parser->cur[0] != 't'))
224 parser->cur++;
227 if (is08601_date_parse_full_time(parser) <= 0)
230 if (parser->cur != parser->end)
239 struct iso8601_date_parser parser;
242 i_zero(&parser);
243 parser.cur = data;
244 parser.end = data + size;
246 if (iso8601_date_parse_date_time(&parser) <= 0)
249 parser.tm.tm_isdst = -1;
250 timestamp = utc_mktime(&parser.tm);
254 *timezone_offset_r = parser.timezone_offset;
255 *tm_r = parser.tm;
256 *timestamp_r = timestamp - parser.timezone_offset * 60;