![]() |
AlexaClientSDK
3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
|
#include <TimeUtils.h>
Public Member Functions | |
TimeUtils () | |
bool | convertToUtcTimeT (const std::tm *utcTm, std::time_t *ret) |
bool | convert8601TimeStringToUnix (const std::string &timeString, int64_t *unixTime) |
bool | convert8601TimeStringToUtcTimePoint (const std::string &iso8601TimeString, std::chrono::system_clock::time_point *tp) |
bool | getCurrentUnixTime (int64_t *currentTime) |
bool | convertTimeToUtcIso8601Rfc3339 (const std::chrono::system_clock::time_point &tp, std::string *iso8601TimeString) |
Class used to safely access the time utilities.
alexaClientSDK::avsCommon::utils::timing::TimeUtils::TimeUtils | ( | ) |
Constructor.
bool alexaClientSDK::avsCommon::utils::timing::TimeUtils::convert8601TimeStringToUnix | ( | const std::string & | timeString, |
int64_t * | unixTime | ||
) |
This function converts a string representing time, encoded in the ISO-8601 format, to what is commonly known as Unix time (epoch).
For completeness, the expected format of the input string is as follows:
YYYY-MM-DDTHH:MM:SS+0000
Where (in order of listing) : Y means year M means month D means day H means hour M means minute S means second
So, for example:
1986-08-08T21:30:00+0000
means the year 1986, August 8th, 9:30pm.
timeString | The time string, formatted as described above. | |
[out] | unixTime | The converted time into Unix epoch time. |
bool alexaClientSDK::avsCommon::utils::timing::TimeUtils::convert8601TimeStringToUtcTimePoint | ( | const std::string & | iso8601TimeString, |
std::chrono::system_clock::time_point * | tp | ||
) |
Converts a ISO 8601 date-time string to a timepoint. Referring to function convert8601TimeStringToUnix
for details of the string representation in ISO 8601 format.
iso8601TimeString | The time string in a ISO 8601 format. | |
[out] | tp | The converted time into UTC time point format. |
bool alexaClientSDK::avsCommon::utils::timing::TimeUtils::convertTimeToUtcIso8601Rfc3339 | ( | const std::chrono::system_clock::time_point & | tp, |
std::string * | iso8601TimeString | ||
) |
Convert timepoint to a ISO 8601 RFC 3339 date-time string. This follows these specifications:
The end result will look like "1970-01-01T00:00:00.000Z"
tp | The timepoint from which to convert. | |
[out] | iso8601TimeString | The resulting time string. |
bool alexaClientSDK::avsCommon::utils::timing::TimeUtils::convertToUtcTimeT | ( | const std::tm * | utcTm, |
std::time_t * | ret | ||
) |
Convert tm struct to time_t in UTC time
This function is needed because mktime uses the current timezone. Hence, we calculate the current timezone difference, and adjust the converted time.
utcTm | time to be converted. This should be in UTC time | |
[out] | ret | The converted UTC time to time_t |
bool alexaClientSDK::avsCommon::utils::timing::TimeUtils::getCurrentUnixTime | ( | int64_t * | currentTime | ) |
Gets the current time in Unix epoch time, as a 64 bit integer.
[out] | currentTime | The current time in Unix epoch time, as a 64 bit integer. |
AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0