@@ -504,17 +504,18 @@ SntpStatus_t Sntp_CalculatePollInterval( uint16_t clockFreqTolerance,
504
504
* @brief Utility to convert SNTP timestamp (that uses 1st Jan 1900 as the epoch) to
505
505
* UNIX timestamp (that uses 1st Jan 1970 as the epoch).
506
506
*
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.
518
519
*
519
520
* @param[in] pSntpTime The SNTP timestamp to convert to UNIX time.
520
521
* @param[out] pUnixTimeSecs This will be filled with the seconds part of the
@@ -525,13 +526,15 @@ SntpStatus_t Sntp_CalculatePollInterval( uint16_t clockFreqTolerance,
525
526
* @return Returns one of the following:
526
527
* - #SntpSuccess if conversion to UNIX time is successful
527
528
* - #SntpErrorBadParameter if any of the passed parameters are NULL.
529
+ * - #SntpErrorTimeNotSupported if the SNTP time lies outside the supported conversion range.
528
530
*/
529
531
/* @[define_sntp_converttounixtime] */
530
532
SntpStatus_t Sntp_ConvertToUnixTime ( const SntpTimestamp_t * pSntpTime ,
531
533
UnixTime_t * pUnixTimeSecs ,
532
534
uint32_t * pUnixTimeMicrosecs );
533
535
/* @[define_sntp_converttounixtime] */
534
536
537
+
535
538
/* *INDENT-OFF* */
536
539
#ifdef __cplusplus
537
540
}
0 commit comments