A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd

timefuncs: add dostime_localtime function

This does the opposite of dostime_mktime, converting time_t back to
the two dos date time values. We use gmtime_r for native because that
is what is available and acts the same as localtime_r on other platforms
with a regular libc available.

Change-Id: If79469d0aae2d7c5dcdd905fbf04963669aa1138

+18
+17
firmware/common/timefuncs.c
··· 46 46 return mktime(&tm); 47 47 } 48 48 49 + void dostime_localtime(time_t time, uint16_t* dosdate, uint16_t* dostime) 50 + { 51 + struct tm tm; 52 + #if (CONFIG_PLATFORM & PLATFORM_NATIVE) 53 + gmtime_r(&time, &tm); 54 + #else 55 + localtime_r(&time, &tm); 56 + #endif 57 + 58 + *dostime = ((tm.tm_sec / 2) << 0)| 59 + ((tm.tm_min ) << 5)| 60 + ((tm.tm_hour ) << 11); 61 + *dosdate = ((tm.tm_mday ) << 0)| 62 + ((tm.tm_mon + 1) << 5)| 63 + ((tm.tm_year - 80) << 9); 64 + } 65 + 49 66 #if !CONFIG_RTC 50 67 static inline bool rtc_dirty(void) 51 68 {
+1
firmware/include/timefuncs.h
··· 28 28 #include "time.h" 29 29 30 30 time_t dostime_mktime(uint16_t dosdate, uint16_t dostime); 31 + void dostime_localtime(time_t time, uint16_t* dosdate, uint16_t* dostime); 31 32 struct tm *get_time(void); 32 33 int set_time(const struct tm *tm); 33 34 #if CONFIG_RTC