|
28 | 28 | extern "C" {
|
29 | 29 | #endif
|
30 | 30 |
|
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. |
34 | 32 | *
|
| 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. |
35 | 36 | * @note - For use by the HAL only
|
36 | 37 | */
|
37 | 38 | bool _rtc_is_leap_year(int year);
|
38 | 39 |
|
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: |
44 | 48 | * - tm_sec
|
45 | 49 | * - tm_min
|
46 | 50 | * - tm_hour
|
47 | 51 | * - tm_mday
|
48 | 52 | * - tm_mon
|
49 | 53 | * - 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). |
55 | 60 | *
|
| 61 | + * @note Leap seconds are not supported. |
| 62 | + * @note Values in output range from 0 to INT_MAX. |
56 | 63 | * @note - For use by the HAL only
|
57 | 64 | */
|
58 |
| -time_t _rtc_mktime(const struct tm* time); |
| 65 | +time_t _rtc_mktime(const struct tm* calendar_time); |
59 | 66 |
|
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: |
65 | 77 | * - tm_sec
|
66 | 78 | * - tm_min
|
67 | 79 | * - tm_hour
|
68 | 80 | * - tm_mday
|
69 | 81 | * - tm_mon
|
70 | 82 | * - 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. |
73 | 85 | *
|
74 | 86 | * @note - For use by the HAL only
|
75 | 87 | */
|
76 |
| -bool _rtc_localtime(time_t timestamp, struct tm* time_info); |
| 88 | +bool _rtc_localtime(time_t timestamp, struct tm* calendar_time); |
77 | 89 |
|
78 | 90 | #ifdef __cplusplus
|
79 | 91 | }
|
|
0 commit comments