Skip to content

Commit 946ed35

Browse files
committed
mbed_mktime: Improve documentation for doxygen.
1 parent 547320e commit 946ed35

File tree

2 files changed

+35
-23
lines changed

2 files changed

+35
-23
lines changed

TESTS/mbed_hal/rtc_time/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
using namespace utest::v1;
2525

2626
/*
27-
* regular is_leap_year, see rtc_api.c for the optimized version
27+
* regular is_leap_year, see platform/mbed_mktime.c for the optimized version
2828
*/
2929
bool is_leap_year(int year) {
3030
year = 1900 + year;

platform/mbed_mktime.h

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,52 +28,64 @@
2828
extern "C" {
2929
#endif
3030

31-
/*
32-
* Compute if a year is a leap year or not.
33-
* year 0 is translated into year 1900 CE.
31+
/** Compute if a year is a leap year or not.
3432
*
33+
* @param year The year to test it shall be in the range [70:138]. Year 0 is
34+
* translated into year 1900 CE.
35+
* @return true if the year in input is a leap year and false otherwise.
3536
* @note - For use by the HAL only
3637
*/
3738
bool _rtc_is_leap_year(int year);
3839

39-
/*
40-
* Thread safe (partial) replacement for mktime.
41-
* This function is tailored around the RTC specification and is not a full
42-
* replacement for mktime.
43-
* The fields from tm used are:
40+
/* Convert a calendar time into time since UNIX epoch as a time_t.
41+
*
42+
* This function is a thread safe (partial) replacement for mktime. It is
43+
* tailored around RTC peripherals needs and is not by any mean a complete
44+
* replacement of mktime.
45+
*
46+
* @param calendar_time The calendar time to convert into a time_t since epoch.
47+
* The fields from tm used for the computation are:
4448
* - tm_sec
4549
* - tm_min
4650
* - tm_hour
4751
* - tm_mday
4852
* - tm_mon
4953
* - tm_year
50-
* Other fields are ignored and won't be normalized by the call.
51-
* If the time in input is less than UNIX epoch (1st january of 1970 at 00:00:00),
52-
* then this function consider the input as invalid and will return time_t(-1).
53-
* Values in output range from 0 to INT_MAX.
54-
* Leap seconds are not supported.
54+
* Other fields are ignored and won't be renormalized by a call to this function.
55+
* A valid calendar time is comprised between the 1st january of 1970 at
56+
* 00:00:00 and the 19th of january 2038 at 03:14:07.
57+
*
58+
* @return The calendar time as seconds since UNIX epoch if the input is in the
59+
* valid range. Otherwise ((time_t) -1).
5560
*
61+
* @note Leap seconds are not supported.
62+
* @note Values in output range from 0 to INT_MAX.
5663
* @note - For use by the HAL only
5764
*/
58-
time_t _rtc_mktime(const struct tm* time);
65+
time_t _rtc_mktime(const struct tm* calendar_time);
5966

60-
/*
61-
* Thread safe (partial) replacement for localtime.
62-
* This function is tailored around the RTC specification and is not a full
63-
* replacement for localtime.
64-
* The tm fields filled by this function are:
67+
/* Convert a given time in seconds since epoch into calendar time.
68+
*
69+
* This function is a thread safe (partial) replacement for localtime. It is
70+
* tailored around RTC peripherals specification and is not by any means a
71+
* complete of localtime.
72+
*
73+
* @param timestamp The time (in seconds) to convert into calendar time. Valid
74+
* input are in the range [0 : INT32_MAX].
75+
* @param calendar_time Pointer to the object which will contain the result of
76+
* the conversion. The tm fields filled by this function are:
6577
* - tm_sec
6678
* - tm_min
6779
* - tm_hour
6880
* - tm_mday
6981
* - tm_mon
7082
* - tm_year
71-
* The time in input shall be in the range [0, INT32_MAX] otherwise the function
72-
* will return false and the structure time_info in input will remain untouch.
83+
* The object remains untouched if the time in input is invalid.
84+
* @return true if the conversion was successful, false otherwise.
7385
*
7486
* @note - For use by the HAL only
7587
*/
76-
bool _rtc_localtime(time_t timestamp, struct tm* time_info);
88+
bool _rtc_localtime(time_t timestamp, struct tm* calendar_time);
7789

7890
#ifdef __cplusplus
7991
}

0 commit comments

Comments
 (0)