diff options
author | Alexander Levin <al.le@rockbox.org> | 2009-06-29 14:31:46 +0000 |
---|---|---|
committer | Alexander Levin <al.le@rockbox.org> | 2009-06-29 14:31:46 +0000 |
commit | 44bf40988b060e2a2e9bc032c13b45c5299af01e (patch) | |
tree | e66cd93c0839a8d36cb6146d225838cb632a76ab /firmware/common | |
parent | ffefe0c08bdeeab725ce5fc054b3add4e05a1f7f (diff) |
Make the get_time on non-RTC sims behave like target, i.e. always return a constant time (FS#10390)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21561 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/common')
-rw-r--r-- | firmware/common/timefuncs.c | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/firmware/common/timefuncs.c b/firmware/common/timefuncs.c index 53ca5f3c16..cc54840376 100644 --- a/firmware/common/timefuncs.c +++ b/firmware/common/timefuncs.c @@ -27,9 +27,23 @@ #include "timefuncs.h" #include "debug.h" -#ifndef SIMULATOR +#if !(defined SIMULATOR && CONFIG_RTC) + static struct tm tm; -#endif + +static void fill_default_tm(struct tm *tm) +{ + tm->tm_sec = 0; + tm->tm_min = 0; + tm->tm_hour = 0; + tm->tm_mday = 1; + tm->tm_mon = 0; + tm->tm_year = 70; + tm->tm_wday = 1; + tm->tm_yday = 0; /* Not implemented for now */ + tm->tm_isdst = -1; /* Not implemented for now */ +} +#endif /* !(defined SIMULATOR && CONFIG_RTC)*/ bool valid_time(const struct tm *tm) { @@ -72,32 +86,30 @@ struct tm *get_time(void) 1964+nn here to make leap years work correctly, so the date will be one year off in the iriver firmware but at least won't be reset anymore. */ tm.tm_year = ((rtcbuf[6] & 0xf0) >> 4) * 10 + (rtcbuf[6] & 0x0f) + 64; -#else +#else /* Not IRIVER_H300_SERIES */ tm.tm_year = ((rtcbuf[6] & 0xf0) >> 4) * 10 + (rtcbuf[6] & 0x0f) + 100; -#endif +#endif /* IRIVER_H300_SERIES */ tm.tm_yday = 0; /* Not implemented for now */ tm.tm_isdst = -1; /* Not implemented for now */ -#else +#else /* CONFIG_RTC == RTC_JZ47XX */ rtc_read_datetime((unsigned char*)&tm); -#endif +#endif /* CONFIG_RTC */ } -#else - tm.tm_sec = 0; - tm.tm_min = 0; - tm.tm_hour = 0; - tm.tm_mday = 1; - tm.tm_mon = 0; - tm.tm_year = 70; - tm.tm_wday = 1; - tm.tm_yday = 0; /* Not implemented for now */ - tm.tm_isdst = -1; /* Not implemented for now */ -#endif +#else /* No RTC */ + fill_default_tm(&tm); +#endif /* RTC */ return &tm; -#else + +#else /* SIMULATOR */ +#if CONFIG_RTC time_t now = time(NULL); return localtime(&now); +#else /* Simulator, no RTC */ + fill_default_tm(&tm); + return &tm; #endif +#endif /* SIMULATOR */ } int set_time(const struct tm *tm) |