Commit 34068bc2 authored by Christian Stenger's avatar Christian Stenger

CPaster: Fix expiry determination

Change-Id: I353a11d06d7feab8a3cfefb54380058532682b59
Reviewed-by: default avatarFriedemann Kleint <Friedemann.Kleint@digia.com>
parent 3fb56d4f
...@@ -44,11 +44,11 @@ enum { debug = 0 }; ...@@ -44,11 +44,11 @@ enum { debug = 0 };
static inline QByteArray expiryParameter(int daysRequested) static inline QByteArray expiryParameter(int daysRequested)
{ {
// Obtained by 'pastebin.kde.org/api/xml/parameter/expire' on 11.11.2013 // Obtained by 'pastebin.kde.org/api/xml/parameter/expire' on 26.03.2014
static const int expiryTimesMin[] = {1800, 21600, 86400, 604800, 2592000}; static const int expiryTimesSec[] = {1800, 21600, 86400, 604800, 2592000, 31536000};
const int *end = expiryTimesMin + sizeof(expiryTimesMin) / sizeof(expiryTimesMin[0]); const int *end = expiryTimesSec + sizeof(expiryTimesSec) / sizeof(expiryTimesSec[0]);
// Find the first element >= requested span, search up to n - 1 such that 'end' defaults to last value. // Find the first element >= requested span, search up to n - 1 such that 'end' defaults to last value.
const int *match = std::lower_bound(expiryTimesMin, end - 1, 24 * 60 * daysRequested); const int *match = std::lower_bound(expiryTimesSec, end - 1, 24 * 60 * 60 * daysRequested);
return QByteArray("expire=") + QByteArray::number(*match); return QByteArray("expire=") + QByteArray::number(*match);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment