summaryrefslogtreecommitdiff
path: root/firmware/common/timefuncs.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/common/timefuncs.c')
-rw-r--r--firmware/common/timefuncs.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/firmware/common/timefuncs.c b/firmware/common/timefuncs.c
index d87e6b67f2..66854dea13 100644
--- a/firmware/common/timefuncs.c
+++ b/firmware/common/timefuncs.c
@@ -46,6 +46,23 @@ time_t dostime_mktime(uint16_t dosdate, uint16_t dostime)
46 return mktime(&tm); 46 return mktime(&tm);
47} 47}
48 48
49void 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#if !CONFIG_RTC 66#if !CONFIG_RTC
50static inline bool rtc_dirty(void) 67static inline bool rtc_dirty(void)
51{ 68{