From 5721b3ac3f8f54b3d13d440784408fee16aadb5f Mon Sep 17 00:00:00 2001 From: alle Date: Mon, 29 Jun 2009 14:31:46 +0000 Subject: [PATCH] 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 --- firmware/common/timefuncs.c | 48 ++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/firmware/common/timefuncs.c b/firmware/common/timefuncs.c index 53ca5f3c1..cc5484037 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) -- 2.11.4.GIT