Skip to content

Commit 796c591

Browse files
committed
Address review comments
1 parent 3ea76fa commit 796c591

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

docs/doxygen/code_examples/example_sntp_client_posix.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ static void sntpClient_SetTime( const SntpServerInfo_t * pTimeServer,
139139
SntpLeapSecondInfo_t leapSecondInfo )
140140
{
141141
/* @[code_example_sntp_converttounixtime] */
142-
uint32_t unixSecs;
142+
UnixTime_t unixSecs;
143143
uint32_t unixMs;
144144
SntpStatus_t status = Sntp_ConvertToUnixTime( pServerTime, &unixSecs, &unixMs );
145145

source/include/core_sntp_serializer.h

+14-11
Original file line numberDiff line numberDiff line change
@@ -504,17 +504,18 @@ SntpStatus_t Sntp_CalculatePollInterval( uint16_t clockFreqTolerance,
504504
* @brief Utility to convert SNTP timestamp (that uses 1st Jan 1900 as the epoch) to
505505
* UNIX timestamp (that uses 1st Jan 1970 as the epoch).
506506
*
507-
* @note This function can ONLY handle conversions of SNTP timestamps that lie in the
508-
* range from 1st Jan 1970 0h 0m 0s, the UNIX epoch time, to 19th Jan 2038 3h 14m 7s,
509-
* the maximum UNIX time that can be represented in a signed 32 bit integer. (The
510-
* limitation is to support systems that use signed 32-bit integer to represent the
511-
* seconds part of the UNIX time.)
512-
*
513-
* @note This function supports overflow of the SNTP timestamp (from the 7 Feb 2036
514-
* 6h 28m 16s time, i.e. SNTP era 1) by treating the timestamps with seconds part
515-
* in the range [0, 61,505,152] seconds where the upper limit represents the UNIX
516-
* overflow time (i.e. 19 Jan 2038 3h 14m 7s) for systems that use signed 32-bit
517-
* integer to represent time.
507+
* @note This function converts SNTP timestamps to UNIX time supporting both 32-bit and
508+
* 64-bit representations based on the configuration macro USE_LEGACY_TIME_API.
509+
*
510+
* - If USE_LEGACY_TIME_API is defined, the conversion is limited to the date range
511+
* from 1st Jan 1970 0h 0m 0s (UNIX epoch) to 19th Jan 2038 3h 14m 7s, due to the
512+
* 32-bit width limitation.
513+
*
514+
* - If USE_LEGACY_TIME_API is not defined, 64-bit UNIX time representation is used,
515+
* allowing conversion of SNTP timestamps beyond the year 2038 (Y2038 problem mitigated).
516+
*
517+
* @note The function also correctly handles SNTP era overflow (from 7 Feb 2036 6h 28m 16s,
518+
* i.e., SNTP era 1) to ensure accurate conversion across SNTP eras.
518519
*
519520
* @param[in] pSntpTime The SNTP timestamp to convert to UNIX time.
520521
* @param[out] pUnixTimeSecs This will be filled with the seconds part of the
@@ -525,13 +526,15 @@ SntpStatus_t Sntp_CalculatePollInterval( uint16_t clockFreqTolerance,
525526
* @return Returns one of the following:
526527
* - #SntpSuccess if conversion to UNIX time is successful
527528
* - #SntpErrorBadParameter if any of the passed parameters are NULL.
529+
* - #SntpErrorTimeNotSupported if the SNTP time lies outside the supported conversion range.
528530
*/
529531
/* @[define_sntp_converttounixtime] */
530532
SntpStatus_t Sntp_ConvertToUnixTime( const SntpTimestamp_t * pSntpTime,
531533
UnixTime_t * pUnixTimeSecs,
532534
uint32_t * pUnixTimeMicrosecs );
533535
/* @[define_sntp_converttounixtime] */
534536

537+
535538
/* *INDENT-OFF* */
536539
#ifdef __cplusplus
537540
}

0 commit comments

Comments
 (0)