summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-item.cc8
-rw-r--r--apt-pkg/acquire-method.cc6
-rw-r--r--apt-pkg/contrib/strutl.cc10
-rw-r--r--apt-pkg/contrib/strutl.h12
-rw-r--r--apt-pkg/edsp.cc4
5 files changed, 29 insertions, 11 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 5ae9229d9..71cb18811 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -1167,7 +1167,7 @@ string pkgAcqMetaBase::Custom600Headers() const
string const FinalFile = GetFinalFilename();
struct stat Buf;
if (stat(FinalFile.c_str(),&Buf) == 0)
- Header += "\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
+ Header += "\nLast-Modified: " + TimeRFC1123(Buf.st_mtime, false);
return Header;
}
@@ -1916,7 +1916,7 @@ void pkgAcqBaseIndex::Failed(std::string const &Message,pkgAcquire::MethodConfig
if (timespec == 0)
ErrorText.append("<unknown>");
else
- ErrorText.append(TimeRFC1123(timespec));
+ ErrorText.append(TimeRFC1123(timespec, true));
ErrorText.append("\n");
}
/*}}}*/
@@ -1969,7 +1969,7 @@ string pkgAcqDiffIndex::Custom600Headers() const
if (stat(Final.c_str(),&Buf) != 0)
return "\nIndex-File: true";
- return "\nIndex-File: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
+ return "\nIndex-File: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime, false);
}
/*}}}*/
void pkgAcqDiffIndex::QueueOnIMSHit() const /*{{{*/
@@ -2881,7 +2881,7 @@ string pkgAcqIndex::Custom600Headers() const
struct stat Buf;
if (stat(Final.c_str(),&Buf) == 0)
- msg += "\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
+ msg += "\nLast-Modified: " + TimeRFC1123(Buf.st_mtime, false);
}
if(Target.IsOptional)
diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc
index 82f4b626d..a9fff661b 100644
--- a/apt-pkg/acquire-method.cc
+++ b/apt-pkg/acquire-method.cc
@@ -148,7 +148,7 @@ void pkgAcqMethod::URIStart(FetchResult &Res)
std::cout << "Size: " << std::to_string(Res.Size) << "\n";
if (Res.LastModified != 0)
- std::cout << "Last-Modified: " << TimeRFC1123(Res.LastModified) << "\n";
+ std::cout << "Last-Modified: " << TimeRFC1123(Res.LastModified, true) << "\n";
if (Res.ResumePoint != 0)
std::cout << "Resume-Point: " << std::to_string(Res.ResumePoint) << "\n";
@@ -187,7 +187,7 @@ void pkgAcqMethod::URIDone(FetchResult &Res, FetchResult *Alt)
std::cout << "Size: " << std::to_string(Res.Size) << "\n";
if (Res.LastModified != 0)
- std::cout << "Last-Modified: " << TimeRFC1123(Res.LastModified) << "\n";
+ std::cout << "Last-Modified: " << TimeRFC1123(Res.LastModified, true) << "\n";
printHashStringList(&Res.Hashes);
@@ -216,7 +216,7 @@ void pkgAcqMethod::URIDone(FetchResult &Res, FetchResult *Alt)
std::cout << "Alt-Size: " << std::to_string(Alt->Size) << "\n";
if (Alt->LastModified != 0)
- std::cout << "Alt-Last-Modified: " << TimeRFC1123(Alt->LastModified) << "\n";
+ std::cout << "Alt-Last-Modified: " << TimeRFC1123(Alt->LastModified, true) << "\n";
printHashStringList(&Alt->Hashes);
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index d0bc938e4..7b6bb2854 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -750,6 +750,10 @@ int StringToBool(const string &Text,int Default)
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)
return "";
@@ -757,10 +761,14 @@ string TimeRFC1123(time_t Date)
auto const posix = std::locale("C.UTF-8");
std::ostringstream datestr;
datestr.imbue(posix);
- APT::StringView const fmt("%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();
}
/*}}}*/
diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h
index a32aaf06d..f3591d65f 100644
--- a/apt-pkg/contrib/strutl.h
+++ b/apt-pkg/contrib/strutl.h
@@ -66,7 +66,17 @@ std::string TimeToStr(unsigned long Sec);
std::string Base64Encode(const std::string &Str);
std::string OutputInDepth(const unsigned long Depth, const char* Separator=" ");
std::string URItoFileName(const std::string &URI);
-std::string TimeRFC1123(time_t Date);
+APT_DEPRECATED_MSG("Specify if GMT is required or a numeric timezone can be used") std::string TimeRFC1123(time_t Date);
+/** returns a datetime string as needed by HTTP/1.1 and Debian files.
+ *
+ * Note: The date will always be represented in a UTC timezone
+ *
+ * @param Date to be represented as a string
+ * @param NumericTimezone is preferred in general, but HTTP/1.1 requires the use
+ * of GMT as timezone instead. \b true means that the timezone should be denoted
+ * as "+0000" while \b false uses "GMT".
+ */
+std::string TimeRFC1123(time_t Date, bool const NumericTimezone);
/** parses time as needed by HTTP/1.1 and Debian files.
*
* HTTP/1.1 prefers dates in RFC1123 format (but the other two obsolete date formats
diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc
index 55bc0fcbd..27b269fd2 100644
--- a/apt-pkg/edsp.cc
+++ b/apt-pkg/edsp.cc
@@ -911,14 +911,14 @@ bool EDSP::WriteSolutionStanza(FileFd &output, char const * const Type, pkgCache
/*}}}*/
// EDSP::WriteProgess - pulse to the given file descriptor /*{{{*/
bool EDSP::WriteProgress(unsigned short const percent, const char* const message, FILE* output) {
- fprintf(output, "Progress: %s\n", TimeRFC1123(time(NULL)).c_str());
+ fprintf(output, "Progress: %s\n", TimeRFC1123(time(NULL), true).c_str());
fprintf(output, "Percentage: %d\n", percent);
fprintf(output, "Message: %s\n\n", message);
fflush(output);
return true;
}
bool EDSP::WriteProgress(unsigned short const percent, const char* const message, FileFd &output) {
- return WriteOkay(output, "Progress: ", TimeRFC1123(time(NULL)), "\n",
+ return WriteOkay(output, "Progress: ", TimeRFC1123(time(NULL), true), "\n",
"Percentage: ", percent, "\n",
"Message: ", message, "\n\n") && output.Flush();
}