mirror of https://github.com/ARMmbed/mbed-os.git
mbed_mktime: Improve documentation for doxygen.
parent
547320e99c
commit
946ed353bc
|
@ -24,7 +24,7 @@
|
||||||
using namespace utest::v1;
|
using namespace utest::v1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* regular is_leap_year, see rtc_api.c for the optimized version
|
* regular is_leap_year, see platform/mbed_mktime.c for the optimized version
|
||||||
*/
|
*/
|
||||||
bool is_leap_year(int year) {
|
bool is_leap_year(int year) {
|
||||||
year = 1900 + year;
|
year = 1900 + year;
|
||||||
|
|
|
@ -28,52 +28,64 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/** Compute if a year is a leap year or not.
|
||||||
* Compute if a year is a leap year or not.
|
|
||||||
* year 0 is translated into year 1900 CE.
|
|
||||||
*
|
*
|
||||||
|
* @param year The year to test it shall be in the range [70:138]. Year 0 is
|
||||||
|
* translated into year 1900 CE.
|
||||||
|
* @return true if the year in input is a leap year and false otherwise.
|
||||||
* @note - For use by the HAL only
|
* @note - For use by the HAL only
|
||||||
*/
|
*/
|
||||||
bool _rtc_is_leap_year(int year);
|
bool _rtc_is_leap_year(int year);
|
||||||
|
|
||||||
/*
|
/* Convert a calendar time into time since UNIX epoch as a time_t.
|
||||||
* Thread safe (partial) replacement for mktime.
|
*
|
||||||
* This function is tailored around the RTC specification and is not a full
|
* This function is a thread safe (partial) replacement for mktime. It is
|
||||||
* replacement for mktime.
|
* tailored around RTC peripherals needs and is not by any mean a complete
|
||||||
* The fields from tm used are:
|
* replacement of mktime.
|
||||||
|
*
|
||||||
|
* @param calendar_time The calendar time to convert into a time_t since epoch.
|
||||||
|
* The fields from tm used for the computation are:
|
||||||
* - tm_sec
|
* - tm_sec
|
||||||
* - tm_min
|
* - tm_min
|
||||||
* - tm_hour
|
* - tm_hour
|
||||||
* - tm_mday
|
* - tm_mday
|
||||||
* - tm_mon
|
* - tm_mon
|
||||||
* - tm_year
|
* - tm_year
|
||||||
* Other fields are ignored and won't be normalized by the call.
|
* Other fields are ignored and won't be renormalized by a call to this function.
|
||||||
* If the time in input is less than UNIX epoch (1st january of 1970 at 00:00:00),
|
* A valid calendar time is comprised between the 1st january of 1970 at
|
||||||
* then this function consider the input as invalid and will return time_t(-1).
|
* 00:00:00 and the 19th of january 2038 at 03:14:07.
|
||||||
* Values in output range from 0 to INT_MAX.
|
|
||||||
* Leap seconds are not supported.
|
|
||||||
*
|
*
|
||||||
|
* @return The calendar time as seconds since UNIX epoch if the input is in the
|
||||||
|
* valid range. Otherwise ((time_t) -1).
|
||||||
|
*
|
||||||
|
* @note Leap seconds are not supported.
|
||||||
|
* @note Values in output range from 0 to INT_MAX.
|
||||||
* @note - For use by the HAL only
|
* @note - For use by the HAL only
|
||||||
*/
|
*/
|
||||||
time_t _rtc_mktime(const struct tm* time);
|
time_t _rtc_mktime(const struct tm* calendar_time);
|
||||||
|
|
||||||
/*
|
/* Convert a given time in seconds since epoch into calendar time.
|
||||||
* Thread safe (partial) replacement for localtime.
|
*
|
||||||
* This function is tailored around the RTC specification and is not a full
|
* This function is a thread safe (partial) replacement for localtime. It is
|
||||||
* replacement for localtime.
|
* tailored around RTC peripherals specification and is not by any means a
|
||||||
* The tm fields filled by this function are:
|
* complete of localtime.
|
||||||
|
*
|
||||||
|
* @param timestamp The time (in seconds) to convert into calendar time. Valid
|
||||||
|
* input are in the range [0 : INT32_MAX].
|
||||||
|
* @param calendar_time Pointer to the object which will contain the result of
|
||||||
|
* the conversion. The tm fields filled by this function are:
|
||||||
* - tm_sec
|
* - tm_sec
|
||||||
* - tm_min
|
* - tm_min
|
||||||
* - tm_hour
|
* - tm_hour
|
||||||
* - tm_mday
|
* - tm_mday
|
||||||
* - tm_mon
|
* - tm_mon
|
||||||
* - tm_year
|
* - tm_year
|
||||||
* The time in input shall be in the range [0, INT32_MAX] otherwise the function
|
* The object remains untouched if the time in input is invalid.
|
||||||
* will return false and the structure time_info in input will remain untouch.
|
* @return true if the conversion was successful, false otherwise.
|
||||||
*
|
*
|
||||||
* @note - For use by the HAL only
|
* @note - For use by the HAL only
|
||||||
*/
|
*/
|
||||||
bool _rtc_localtime(time_t timestamp, struct tm* time_info);
|
bool _rtc_localtime(time_t timestamp, struct tm* calendar_time);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue