Lines Matching refs:datetime
44 static bool SNVS_HP_CheckDatetimeFormat(const snvs_hp_rtc_datetime_t *datetime);
53 static uint32_t SNVS_HP_ConvertDatetimeToSeconds(const snvs_hp_rtc_datetime_t *datetime);
61 static void SNVS_HP_ConvertSecondsToDatetime(uint32_t seconds, snvs_hp_rtc_datetime_t *datetime);
98 static bool SNVS_HP_CheckDatetimeFormat(const snvs_hp_rtc_datetime_t *datetime) in SNVS_HP_CheckDatetimeFormat() argument
100 assert(datetime != NULL); in SNVS_HP_CheckDatetimeFormat()
108 …if ((datetime->year < YEAR_RANGE_START) || (datetime->year > YEAR_RANGE_END) || (datetime->month >… in SNVS_HP_CheckDatetimeFormat()
109 …(datetime->month < 1U) || (datetime->hour >= 24U) || (datetime->minute >= 60U) || (datetime->secon… in SNVS_HP_CheckDatetimeFormat()
116 …if ((((datetime->year & 3U) == 0U) && (datetime->year % 100U != 0U)) || (datetime->year % 400U == … in SNVS_HP_CheckDatetimeFormat()
122 if ((datetime->day > daysPerMonth[datetime->month]) || (datetime->day < 1U)) in SNVS_HP_CheckDatetimeFormat()
130 static uint32_t SNVS_HP_ConvertDatetimeToSeconds(const snvs_hp_rtc_datetime_t *datetime) in SNVS_HP_ConvertDatetimeToSeconds() argument
132 assert(datetime != NULL); in SNVS_HP_ConvertDatetimeToSeconds()
140 seconds = (((uint32_t)datetime->year - 1970U) * DAYS_IN_A_YEAR); in SNVS_HP_ConvertDatetimeToSeconds()
142 seconds += (((uint32_t)datetime->year / 4U) - (1970U / 4U)); in SNVS_HP_ConvertDatetimeToSeconds()
144 seconds += monthDays[datetime->month]; in SNVS_HP_ConvertDatetimeToSeconds()
147 seconds += ((uint32_t)datetime->day - 1U); in SNVS_HP_ConvertDatetimeToSeconds()
149 if ((0U == (datetime->year & 3U)) && (datetime->month <= 2U)) in SNVS_HP_ConvertDatetimeToSeconds()
154 seconds = (seconds * SECONDS_IN_A_DAY) + (datetime->hour * SECONDS_IN_A_HOUR) + in SNVS_HP_ConvertDatetimeToSeconds()
155 (datetime->minute * SECONDS_IN_A_MINUTE) + datetime->second; in SNVS_HP_ConvertDatetimeToSeconds()
160 static void SNVS_HP_ConvertSecondsToDatetime(uint32_t seconds, snvs_hp_rtc_datetime_t *datetime) in SNVS_HP_ConvertSecondsToDatetime() argument
162 assert(datetime != NULL); in SNVS_HP_ConvertSecondsToDatetime()
184 datetime->hour = (uint8_t)(secondsRemaining / SECONDS_IN_A_HOUR); in SNVS_HP_ConvertSecondsToDatetime()
186 datetime->minute = (uint8_t)(secondsRemaining / 60U); in SNVS_HP_ConvertSecondsToDatetime()
187 datetime->second = (uint8_t)(secondsRemaining % SECONDS_IN_A_MINUTE); in SNVS_HP_ConvertSecondsToDatetime()
191 datetime->year = YEAR_RANGE_START; in SNVS_HP_ConvertSecondsToDatetime()
196 datetime->year++; in SNVS_HP_ConvertSecondsToDatetime()
199 if ((datetime->year & 3U) != 0U) in SNVS_HP_ConvertSecondsToDatetime()
210 if (0U == (datetime->year & 3U)) in SNVS_HP_ConvertSecondsToDatetime()
219 datetime->month = (uint8_t)x; in SNVS_HP_ConvertSecondsToDatetime()
228 datetime->day = (uint8_t)days; in SNVS_HP_ConvertSecondsToDatetime()
362 status_t SNVS_HP_RTC_SetDatetime(SNVS_Type *base, const snvs_hp_rtc_datetime_t *datetime) in SNVS_HP_RTC_SetDatetime() argument
364 assert(datetime != NULL); in SNVS_HP_RTC_SetDatetime()
373 if (!(SNVS_HP_CheckDatetimeFormat(datetime))) in SNVS_HP_RTC_SetDatetime()
379 seconds = SNVS_HP_ConvertDatetimeToSeconds(datetime); in SNVS_HP_RTC_SetDatetime()
399 void SNVS_HP_RTC_GetDatetime(SNVS_Type *base, snvs_hp_rtc_datetime_t *datetime) in SNVS_HP_RTC_GetDatetime() argument
401 assert(datetime != NULL); in SNVS_HP_RTC_GetDatetime()
403 SNVS_HP_ConvertSecondsToDatetime(SNVS_HP_RTC_GetSeconds(base), datetime); in SNVS_HP_RTC_GetDatetime()
465 void SNVS_HP_RTC_GetAlarm(SNVS_Type *base, snvs_hp_rtc_datetime_t *datetime) in SNVS_HP_RTC_GetAlarm() argument
467 assert(datetime != NULL); in SNVS_HP_RTC_GetAlarm()
475 SNVS_HP_ConvertSecondsToDatetime(alarmSeconds, datetime); in SNVS_HP_RTC_GetAlarm()