From cfc6566d5097ef5518e12f5c1e5f15a8f5b182cf Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 29 Jun 2016 11:00:04 +0200 Subject: Revert "travis: use gcc-5 instead of gcc(-4.8)" This reverts commit 2b8221d66a8284042fc53c7bbb14bb9750e9137f. Avoiding the use of GCC >= 5 stuff lets use go back to 4.8 simplifying the travis setup again as well as reducing the backport requirements in general. This is possible because the std::get_time use requiring GCC >= 5 in 9febc2b238e1e322dce1f94ecbed46d595893b52 was replaced by handrolling it in 1d742e01470bba27715a8191c50adde4b39c2f19, so the remaining uses are just small conviniences we can do without. Gbp-Dch: Ignore --- ftparchive/writer.cc | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'ftparchive') diff --git a/ftparchive/writer.cc b/ftparchive/writer.cc index 1036ce0b8..dbeaa16a6 100644 --- a/ftparchive/writer.cc +++ b/ftparchive/writer.cc @@ -967,6 +967,15 @@ bool ContentsWriter::ReadFromPkgs(string const &PkgFile,string const &PkgCompres // ReleaseWriter::ReleaseWriter - Constructor /*{{{*/ // --------------------------------------------------------------------- /* */ +static std::string formatUTCDateTime(time_t const now) +{ + // TimeRFC1123 uses GMT to satisfy HTTP/1.1 + std::string datetime = TimeRFC1123(now); + auto const lastspace = datetime.rfind(' '); + if (likely(lastspace != std::string::npos)) + datetime.replace(lastspace + 1, 3, "UTC"); + return datetime; +} ReleaseWriter::ReleaseWriter(FileFd * const GivenOutput, string const &/*DB*/) : FTWScanner(GivenOutput) { if (_config->FindB("APT::FTPArchive::Release::Default-Patterns", true) == true) @@ -988,20 +997,7 @@ ReleaseWriter::ReleaseWriter(FileFd * const GivenOutput, string const &/*DB*/) : AddPatterns(_config->FindVector("APT::FTPArchive::Release::Patterns")); time_t const now = time(NULL); - auto const posix = std::locale("C.UTF-8"); - - // FIXME: use TimeRFC1123 here? But that uses GMT to satisfy HTTP/1.1 - std::ostringstream datestr; - datestr.imbue(posix); - datestr << std::put_time(gmtime(&now), "%a, %d %b %Y %H:%M:%S UTC"); - time_t const validuntil = now + _config->FindI("APT::FTPArchive::Release::ValidTime", 0); - std::ostringstream validstr; - if (validuntil != now) - { - datestr.imbue(posix); - validstr << std::put_time(gmtime(&validuntil), "%a, %d %b %Y %H:%M:%S UTC"); - } map Fields; Fields["Origin"] = ""; @@ -1009,8 +1005,9 @@ ReleaseWriter::ReleaseWriter(FileFd * const GivenOutput, string const &/*DB*/) : Fields["Suite"] = ""; Fields["Version"] = ""; Fields["Codename"] = ""; - Fields["Date"] = datestr.str(); - Fields["Valid-Until"] = validstr.str(); + Fields["Date"] = formatUTCDateTime(now); + if (validuntil != now) + Fields["Valid-Until"] = formatUTCDateTime(validuntil); Fields["Architectures"] = ""; Fields["Components"] = ""; Fields["Description"] = ""; -- cgit v1.2.3