[core] Replace time_t with std::chrono::seconds
Added aliases for std::chrono typedefs (eg. 'Seconds' for std::chrono::seconds). These aliases are used together with templated helper functions to replace time_t with std::chrono::seconds for most cases, in particular for 'modified' and 'expires' values in Response.
This commit is contained in:
@@ -5,18 +5,15 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
int64_t HTTPRequestBase::parseCacheControl(const char *value) {
|
||||
Seconds HTTPRequestBase::parseCacheControl(const char *value) {
|
||||
if (value) {
|
||||
const auto cacheControl = http::CacheControl::parse(value);
|
||||
|
||||
if (cacheControl.maxAge) {
|
||||
return std::chrono::duration_cast<std::chrono::seconds>(
|
||||
std::chrono::system_clock::now().time_since_epoch()).count() +
|
||||
*cacheControl.maxAge;
|
||||
return toSeconds(SystemClock::now()) + Seconds(*cacheControl.maxAge);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return Seconds::zero();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user