struct tm tm;
unsigned int secs;
const char *error;
+ int tz;
if (i_isdigit(str[0]) && i_isdigit(str[1]) &&
i_isdigit(str[2]) && i_isdigit(str[3]) && str[4] == '-' &&
*utc_r = TRUE;
return 0;
} else if (imap_parse_date(str, timestamp_r)) {
- /* imap date */
+ /* imap datetime */
*utc_r = FALSE;
return 0;
+ } else if (imap_parse_datetime(str, timestamp_r, &tz)) {
+ /* imap datetime */
+ *utc_r = TRUE;
+ return 0;
} else if (str_to_time(str, timestamp_r) == 0) {
/* unix timestamp */
*utc_r = TRUE;
Returns 0 and timestamp on success, -1 if the string couldn't be parsed.
Currently supported string formats: yyyy-mm-dd (utc=FALSE),
- imap date (utc=FALSE), unix timestamp (utc=TRUE), interval (e.g. n days,
- utc=TRUE). */
+ imap date (utc=FALSE), imap date-time (utc=TRUE), unix timestamp (utc=TRUE),
+ interval (e.g. n days, utc=TRUE). */
int mail_parse_human_timestamp(const char *str, time_t *timestamp_r,
bool *utc_r);
{ "2022-01-21", 1642723200, TRUE },
/* IMAP date */
{ "21-Jan-2022", 1642723200, FALSE },
+ /* IMAP datetime */
+ { "21-Jan-2022 10:00:00 +0300", 1642723200 + 7*3600, TRUE },
/* UNIX timestamp */
{ "1642723200", 1642723200, TRUE },
};
time_t timestamp;
bool is_utc;
- test_begin("mail_parse_human_timestamp");
+ test_begin("mail_parse_human_timestamp()");
for (unsigned int i = 0; i < N_ELEMENTS(human_timestamp_tests); i++) {
ret = mail_parse_human_timestamp(human_timestamp_tests[i].str,