diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/updates.cpp | 10 | ||||
-rw-r--r-- | common/updates.h | 9 |
2 files changed, 19 insertions, 0 deletions
diff --git a/common/updates.cpp b/common/updates.cpp index 0318864881..552324ef5a 100644 --- a/common/updates.cpp +++ b/common/updates.cpp @@ -38,6 +38,16 @@ const int *UpdateManager::getUpdateIntervals() { return updateIntervals; } +int UpdateManager::normalizeInterval(int interval) { + const int *val = updateIntervals; + + while (*val != -1) + if (*val > interval) + return *val; + + return val[-1]; // Return maximal acceptable value +} + const char *UpdateManager::updateIntervalToString(int interval) { switch (interval) { case kUpdateIntervalNotSupported: diff --git a/common/updates.h b/common/updates.h index fa6f79fb91..65eb5ac095 100644 --- a/common/updates.h +++ b/common/updates.h @@ -105,9 +105,18 @@ public: /** * Returns string representation of a given interval. * + * @param interval The interval. * @return pointer to localized string of given interval. */ static const char *updateIntervalToString(int interval); + + /** + * Rounds up the given interval to acceptable value. + * + * @param interval The interval. + * @return rounded up interval + */ + static int normalizeInterval(int interval); }; } // End of namespace Common |