summaryrefslogtreecommitdiff
path: root/src/hearthstoneAPIHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/hearthstoneAPIHandler.cpp')
-rw-r--r--src/hearthstoneAPIHandler.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/hearthstoneAPIHandler.cpp b/src/hearthstoneAPIHandler.cpp
index 7db7b04..ff8aa9b 100644
--- a/src/hearthstoneAPIHandler.cpp
+++ b/src/hearthstoneAPIHandler.cpp
@@ -23,8 +23,8 @@ size_t HearthstoneAPIHandler::curl_callback_string_output(void *t_contents,
return newLength;
}
-std::chrono::hours HearthstoneAPIHandler::get_current_time() {
- return std::chrono::duration_cast<std::chrono::hours>(
+std::chrono::seconds HearthstoneAPIHandler::get_current_time() {
+ return std::chrono::duration_cast<std::chrono::seconds>(
std::chrono::utc_clock::now().time_since_epoch());
}
@@ -64,7 +64,8 @@ void HearthstoneAPIHandler::write_new_token_info_to_file(
}
std::string token =
extract_string_with_regex(token_info, "\"access_token\":\"(\\w+)\"");
- std::chrono::hours expires_at = get_current_time() + std::chrono::hours(24);
+ std::chrono::seconds expires_at =
+ get_current_time() + std::chrono::hours(24);
token_file << token << " " << expires_at.count();
}
@@ -78,7 +79,7 @@ void HearthstoneAPIHandler::refresh_token_if_needed() {
write_new_token_info_to_file(file_path);
} else {
unsigned long expire_at = std::stoull(line.substr(line.find(" ") + 1));
- if (std::chrono::duration_cast<std::chrono::hours>(
+ if (std::chrono::duration_cast<std::chrono::seconds>(
std::chrono::utc_clock::now().time_since_epoch())
.count() >= expire_at) {
write_new_token_info_to_file(file_path);