diff options
author | James Buren <braewoods+rb@braewoods.net> | 2021-07-03 00:19:58 +0000 |
---|---|---|
committer | James Buren <braewoods+rb@braewoods.net> | 2021-07-03 00:19:58 +0000 |
commit | c9f2308a1d4401ceefaac47b1ea851530d07e47d (patch) | |
tree | 81f75a26707bd8583f5117a7a0febba894787996 /firmware/common/timefuncs.c | |
parent | d1a92aafff55defefcb8cf8f4b045701325088b2 (diff) | |
download | rockbox-c9f2308a1d4401ceefaac47b1ea851530d07e47d.tar.gz rockbox-c9f2308a1d4401ceefaac47b1ea851530d07e47d.zip |
fat: move fattime_mktime to timefuncs
This moves the time conversion function to timefuncs since it has
uses on ports that don't use the FAT driver. This function has no
dependency on the FAT driver as it is so this should not cause any
issues. To reflect this separation the function was renamed to
dostime_mktime since it is really for DOS timestamps. The places
where it was used have also been updated.
Change-Id: Id98b1448d5c6fcda286846e1d2c736db682bfb52
Diffstat (limited to 'firmware/common/timefuncs.c')
-rw-r--r-- | firmware/common/timefuncs.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/firmware/common/timefuncs.c b/firmware/common/timefuncs.c index 108431753a..d87e6b67f2 100644 --- a/firmware/common/timefuncs.c +++ b/firmware/common/timefuncs.c | |||
@@ -32,6 +32,20 @@ | |||
32 | 32 | ||
33 | static struct tm tm; | 33 | static struct tm tm; |
34 | 34 | ||
35 | time_t dostime_mktime(uint16_t dosdate, uint16_t dostime) | ||
36 | { | ||
37 | /* this knows our mktime() only uses these struct tm fields */ | ||
38 | struct tm tm; | ||
39 | tm.tm_sec = ((dostime ) & 0x1f) * 2; | ||
40 | tm.tm_min = ((dostime >> 5) & 0x3f); | ||
41 | tm.tm_hour = ((dostime >> 11) ); | ||
42 | tm.tm_mday = ((dosdate ) & 0x1f); | ||
43 | tm.tm_mon = ((dosdate >> 5) & 0x0f) - 1; | ||
44 | tm.tm_year = ((dosdate >> 9) ) + 80; | ||
45 | |||
46 | return mktime(&tm); | ||
47 | } | ||
48 | |||
35 | #if !CONFIG_RTC | 49 | #if !CONFIG_RTC |
36 | static inline bool rtc_dirty(void) | 50 | static inline bool rtc_dirty(void) |
37 | { | 51 | { |