diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/common/timefuncs.c | 17 | ||||
-rw-r--r-- | firmware/include/timefuncs.h | 1 |
2 files changed, 18 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 | ||
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 | #if !CONFIG_RTC | 66 | #if !CONFIG_RTC |
50 | static inline bool rtc_dirty(void) | 67 | static inline bool rtc_dirty(void) |
51 | { | 68 | { |
diff --git a/firmware/include/timefuncs.h b/firmware/include/timefuncs.h index 2e8ef01ca6..25e041b576 100644 --- a/firmware/include/timefuncs.h +++ b/firmware/include/timefuncs.h | |||
@@ -28,6 +28,7 @@ | |||
28 | #include "time.h" | 28 | #include "time.h" |
29 | 29 | ||
30 | time_t dostime_mktime(uint16_t dosdate, uint16_t dostime); | 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 | struct tm *get_time(void); | 32 | struct tm *get_time(void); |
32 | int set_time(const struct tm *tm); | 33 | int set_time(const struct tm *tm); |
33 | #if CONFIG_RTC | 34 | #if CONFIG_RTC |