/* This converts a time_t into a string time representation that is
year 2000 complient and timezone neutral */
string TimeRFC1123(time_t Date)
+{
+ return TimeRFC1123(Date, false);
+}
+string TimeRFC1123(time_t Date, bool const NumericTimezone)
{
struct tm Conv;
if (gmtime_r(&Date, &Conv) == NULL)
auto const posix = std::locale("C.UTF-8");
std::ostringstream datestr;
datestr.imbue(posix);
- datestr << std::put_time(&Conv, "%a, %d %b %Y %H:%M:%S GMT");
+ APT::StringView const fmt("%a, %d %b %Y %H:%M:%S");
+ std::use_facet<std::time_put<char>>(posix).put(
+ std::ostreambuf_iterator<char>(datestr),
+ datestr, ' ', &Conv, fmt.data(), fmt.data() + fmt.size());
+ if (NumericTimezone)
+ datestr << " +0000";
+ else
+ datestr << " GMT";
return datestr.str();
}
/*}}}*/
signed int year = 0; // yes, Y23K problem – we gonna worry then…
std::string weekday, month, datespec, timespec, zone;
std::istringstream ss(str);
+ auto const &posix = std::locale("C.UTF-8");
+ ss.imbue(posix);
ss >> weekday;
// we only superficially check weekday, mostly to avoid accepting localized
// weekdays here and take only its length to decide which datetime format we