diff -r 523fe96baeca -r e676ed461b5b src/server/plugins/postgresql/vfs.c --- a/src/server/plugins/postgresql/vfs.c Mon Apr 25 18:33:03 2022 +0200 +++ b/src/server/plugins/postgresql/vfs.c Mon Apr 25 19:28:52 2022 +0200 @@ -862,14 +862,27 @@ } time_t pg_convert_timestamp(const char *timestamp) { + struct tm tm; + if(pg_convert_timestamp_tm(timestamp, &tm)) { + return 0; + } +#ifdef __FreeBSD__ + return timelocal(&tm); +#else + return mktime(&tparts) - timezone; +#endif +} + +int pg_convert_timestamp_tm(const char *timestamp, struct tm *tm) { // TODO: this is a very basic implementation that needs some work // format yyyy-mm-dd HH:MM:SS + memset(tm, 0, sizeof(struct tm)); size_t len = timestamp ? strlen(timestamp) : 0; if(len < 19) { - return 0; + return 1; } else if(len > 63) { - return 0; + return 1; } char buf[64]; @@ -893,18 +906,12 @@ char *second_str = buf + 17; second_str[2] = '\0'; - struct tm tm; - memset(&tm, 0, sizeof(struct tm)); - tm.tm_year = atoi(year_str) - 1900; - tm.tm_mon = atoi(month_str) - 1; - tm.tm_mday = atoi(day_str); - tm.tm_hour = atoi(hour_str); - tm.tm_min = atoi(minute_str); - tm.tm_sec = atoi(second_str); + tm->tm_year = atoi(year_str) - 1900; + tm->tm_mon = atoi(month_str) - 1; + tm->tm_mday = atoi(day_str); + tm->tm_hour = atoi(hour_str); + tm->tm_min = atoi(minute_str); + tm->tm_sec = atoi(second_str); -#ifdef __FreeBSD__ - return timelocal(&tm); -#else - return mktime(&tparts) - timezone; -#endif + return 0; }