Lines Matching refs:datetime
39 static bool SNVS_LP_CheckDatetimeFormat(const snvs_lp_srtc_datetime_t *datetime);
48 static uint32_t SNVS_LP_ConvertDatetimeToSeconds(const snvs_lp_srtc_datetime_t *datetime);
56 static void SNVS_LP_ConvertSecondsToDatetime(uint32_t seconds, snvs_lp_srtc_datetime_t *datetime);
93 static bool SNVS_LP_CheckDatetimeFormat(const snvs_lp_srtc_datetime_t *datetime) in SNVS_LP_CheckDatetimeFormat() argument
95 assert(datetime != NULL); in SNVS_LP_CheckDatetimeFormat()
103 …if ((datetime->year < YEAR_RANGE_START) || (datetime->year > YEAR_RANGE_END) || (datetime->month >… in SNVS_LP_CheckDatetimeFormat()
104 …(datetime->month < 1U) || (datetime->hour >= 24U) || (datetime->minute >= 60U) || (datetime->secon… in SNVS_LP_CheckDatetimeFormat()
111 …if ((((datetime->year & 3U) == 0U) && (datetime->year % 100U != 0U)) || (datetime->year % 400U == … in SNVS_LP_CheckDatetimeFormat()
117 if ((datetime->day > daysPerMonth[datetime->month]) || (datetime->day < 1U)) in SNVS_LP_CheckDatetimeFormat()
125 static uint32_t SNVS_LP_ConvertDatetimeToSeconds(const snvs_lp_srtc_datetime_t *datetime) in SNVS_LP_ConvertDatetimeToSeconds() argument
127 assert(datetime != NULL); in SNVS_LP_ConvertDatetimeToSeconds()
135 seconds = ((uint32_t)datetime->year - 1970U) * DAYS_IN_A_YEAR; in SNVS_LP_ConvertDatetimeToSeconds()
137 seconds += (((uint32_t)datetime->year / 4U) - (1970U / 4U)); in SNVS_LP_ConvertDatetimeToSeconds()
139 seconds += monthDays[datetime->month]; in SNVS_LP_ConvertDatetimeToSeconds()
142 seconds += ((uint32_t)datetime->day - 1U); in SNVS_LP_ConvertDatetimeToSeconds()
144 if ((0U == (datetime->year & 3U)) && (datetime->month <= 2U)) in SNVS_LP_ConvertDatetimeToSeconds()
149 seconds = (seconds * SECONDS_IN_A_DAY) + (datetime->hour * SECONDS_IN_A_HOUR) + in SNVS_LP_ConvertDatetimeToSeconds()
150 (datetime->minute * SECONDS_IN_A_MINUTE) + datetime->second; in SNVS_LP_ConvertDatetimeToSeconds()
155 static void SNVS_LP_ConvertSecondsToDatetime(uint32_t seconds, snvs_lp_srtc_datetime_t *datetime) in SNVS_LP_ConvertSecondsToDatetime() argument
157 assert(datetime != NULL); in SNVS_LP_ConvertSecondsToDatetime()
179 datetime->hour = (uint8_t)(secondsRemaining / SECONDS_IN_A_HOUR); in SNVS_LP_ConvertSecondsToDatetime()
181 datetime->minute = (uint8_t)(secondsRemaining / 60U); in SNVS_LP_ConvertSecondsToDatetime()
182 datetime->second = (uint8_t)(secondsRemaining % SECONDS_IN_A_MINUTE); in SNVS_LP_ConvertSecondsToDatetime()
186 datetime->year = YEAR_RANGE_START; in SNVS_LP_ConvertSecondsToDatetime()
191 datetime->year++; in SNVS_LP_ConvertSecondsToDatetime()
194 if ((datetime->year & 3U) != 0U) in SNVS_LP_ConvertSecondsToDatetime()
205 if (0U == (datetime->year & 3U)) in SNVS_LP_ConvertSecondsToDatetime()
214 datetime->month = (uint8_t)x; in SNVS_LP_ConvertSecondsToDatetime()
223 datetime->day = (uint8_t)days; in SNVS_LP_ConvertSecondsToDatetime()
371 status_t SNVS_LP_SRTC_SetDatetime(SNVS_Type *base, const snvs_lp_srtc_datetime_t *datetime) in SNVS_LP_SRTC_SetDatetime() argument
373 assert(datetime != NULL); in SNVS_LP_SRTC_SetDatetime()
382 if (!(SNVS_LP_CheckDatetimeFormat(datetime))) in SNVS_LP_SRTC_SetDatetime()
388 seconds = SNVS_LP_ConvertDatetimeToSeconds(datetime); in SNVS_LP_SRTC_SetDatetime()
408 void SNVS_LP_SRTC_GetDatetime(SNVS_Type *base, snvs_lp_srtc_datetime_t *datetime) in SNVS_LP_SRTC_GetDatetime() argument
410 assert(datetime != NULL); in SNVS_LP_SRTC_GetDatetime()
412 SNVS_LP_ConvertSecondsToDatetime(SNVS_LP_SRTC_GetSeconds(base), datetime); in SNVS_LP_SRTC_GetDatetime()
477 void SNVS_LP_SRTC_GetAlarm(SNVS_Type *base, snvs_lp_srtc_datetime_t *datetime) in SNVS_LP_SRTC_GetAlarm() argument
479 assert(datetime != NULL); in SNVS_LP_SRTC_GetAlarm()
486 SNVS_LP_ConvertSecondsToDatetime(alarmSeconds, datetime); in SNVS_LP_SRTC_GetAlarm()