// for big boxes only these will fit void RTC_GetTimeFormattedBigbox(char *str, u32 time) { unsigned am = ((time % DAYSEC) / 3600) < 12; unsigned hour = _RTC_GetHour(time); if (hour == 12) hour = 0; sprintf(str, "%2d:%02d:%02d", hour + (am ? 0 : 12), _RTC_GetMinute(time), _RTC_GetSecond(time)); }
void RTC_GetTimeFormatted(char *str, u32 time) { // which format to use? unsigned format = Transmitter.rtcflags & TIMEFMT; // make sure that the number is correct; use default otherwise if (format >= sizeof(timeformats) / sizeof(timeformats[0])) format = 0; switch (format) { case 0: // "default" = ISO8601 = hh:mm:ss sprintf(str, "%2d:%02d:%02d", _RTC_GetHour(time), _RTC_GetMinute(time), _RTC_GetSecond(time)); break; case 1: // a.m. / p.m. = hh:mm:ss am/pm { unsigned am = ((time % DAYSEC) / 3600) < 12; sprintf(str, "%2d:%02d:%02d %s", _RTC_GetHour(time), _RTC_GetMinute(time), _RTC_GetSecond(time), (am) ? "AM" : "PM"); break; } } }
void RTC_GetTimeGTM(struct gtm *t) { uint32_t value = RTC_GetValue(); t->tm_sec = _RTC_GetSecond(value); t->tm_min = _RTC_GetMinute(value); t->tm_hour = _RTC_GetHour(value); t->tm_mday = _RTC_GetDay(value); t->tm_year = _RTC_GetYear(value) - 1900; }
// format time string void RTC_GetTimeStringShort(char *str, u32 value) { sprintf(str, "%2d:%02d", _RTC_GetHour(value), _RTC_GetMinute(value)); }
// for big boxes only these will fit void RTC_GetTimeFormattedBigbox(char *str, u32 time) { sprintf(str, "%2d:%02d:%02d", _RTC_GetHour(time), _RTC_GetMinute(time), _RTC_GetSecond(time)); }
// format time string void RTC_GetTimeString(char *str, uint32_t value) { sprintf(str, "%2d:%02d:%02d", _RTC_GetHour(value), _RTC_GetMinute(value), _RTC_GetSecond(value)); }