diff options
author | Frank Gevaerts <frank@gevaerts.be> | 2009-08-11 20:03:59 +0000 |
---|---|---|
committer | Frank Gevaerts <frank@gevaerts.be> | 2009-08-11 20:03:59 +0000 |
commit | ceccec503e140ea70c0ac3ecf75c7f45c3fb7a0c (patch) | |
tree | f10a8775453386b9fe226cc620c6a4091f763aa8 | |
parent | 2dc50471ca17eaeb24b45abce4c0f8944cd781d5 (diff) | |
download | rockbox-ceccec503e140ea70c0ac3ecf75c7f45c3fb7a0c.tar.gz rockbox-ceccec503e140ea70c0ac3ecf75c7f45c3fb7a0c.zip |
Move yearday_to_daymonth() to usb_storage.c. It's the only user, this function is pretty specific, and it seems to be the cleanest way to avoid ram usage increases for unrelated targets
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22259 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/common/timefuncs.c | 25 | ||||
-rw-r--r-- | firmware/include/timefuncs.h | 1 | ||||
-rw-r--r-- | firmware/usbstack/usb_storage.c | 25 |
3 files changed, 25 insertions, 26 deletions
diff --git a/firmware/common/timefuncs.c b/firmware/common/timefuncs.c index 774fba9ab0..405bce4f5f 100644 --- a/firmware/common/timefuncs.c +++ b/firmware/common/timefuncs.c | |||
@@ -204,28 +204,3 @@ void set_day_of_week(struct tm *tm) | |||
204 | if(m == 0 || m == 1) y--; | 204 | if(m == 0 || m == 1) y--; |
205 | tm->tm_wday = (d + mo[m] + y + y/4 - y/100 + y/400) % 7; | 205 | tm->tm_wday = (d + mo[m] + y + y/4 - y/100 + y/400) % 7; |
206 | } | 206 | } |
207 | |||
208 | void yearday_to_daymonth(int yd, int y, int *d, int *m) | ||
209 | { | ||
210 | static const char tnl[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; | ||
211 | static const char tl[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; | ||
212 | const char *t; | ||
213 | int i=0; | ||
214 | |||
215 | if((y%4 == 0 && y%100 != 0) || y%400 == 0) | ||
216 | { | ||
217 | t=tl; | ||
218 | } | ||
219 | else | ||
220 | { | ||
221 | t=tnl; | ||
222 | } | ||
223 | |||
224 | while(yd >= t[i] && i<12) | ||
225 | { | ||
226 | yd-=t[i]; | ||
227 | i++; | ||
228 | } | ||
229 | *d = yd+1; | ||
230 | *m = i; | ||
231 | } | ||
diff --git a/firmware/include/timefuncs.h b/firmware/include/timefuncs.h index e9ef8075ac..ab566d9e5f 100644 --- a/firmware/include/timefuncs.h +++ b/firmware/include/timefuncs.h | |||
@@ -30,7 +30,6 @@ struct tm *get_time(void); | |||
30 | int set_time(const struct tm *tm); | 30 | int set_time(const struct tm *tm); |
31 | bool valid_time(const struct tm *tm); | 31 | bool valid_time(const struct tm *tm); |
32 | void set_day_of_week(struct tm *tm); | 32 | void set_day_of_week(struct tm *tm); |
33 | void yearday_to_daymonth(int yd, int y, int *d, int *m); | ||
34 | #if CONFIG_RTC | 33 | #if CONFIG_RTC |
35 | time_t mktime(struct tm *t); | 34 | time_t mktime(struct tm *t); |
36 | #endif | 35 | #endif |
diff --git a/firmware/usbstack/usb_storage.c b/firmware/usbstack/usb_storage.c index a3664b074b..e6a45e613a 100644 --- a/firmware/usbstack/usb_storage.c +++ b/firmware/usbstack/usb_storage.c | |||
@@ -295,6 +295,31 @@ static enum { | |||
295 | SENDING_CSW | 295 | SENDING_CSW |
296 | } state = WAITING_FOR_COMMAND; | 296 | } state = WAITING_FOR_COMMAND; |
297 | 297 | ||
298 | static void yearday_to_daymonth(int yd, int y, int *d, int *m) | ||
299 | { | ||
300 | static const char tnl[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; | ||
301 | static const char tl[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; | ||
302 | const char *t; | ||
303 | int i=0; | ||
304 | |||
305 | if((y%4 == 0 && y%100 != 0) || y%400 == 0) | ||
306 | { | ||
307 | t=tl; | ||
308 | } | ||
309 | else | ||
310 | { | ||
311 | t=tnl; | ||
312 | } | ||
313 | |||
314 | while(yd >= t[i] && i<12) | ||
315 | { | ||
316 | yd-=t[i]; | ||
317 | i++; | ||
318 | } | ||
319 | *d = yd+1; | ||
320 | *m = i; | ||
321 | } | ||
322 | |||
298 | #ifdef TOSHIBA_GIGABEAT_S | 323 | #ifdef TOSHIBA_GIGABEAT_S |
299 | 324 | ||
300 | /* The Gigabeat S factory partition table contains invalid values for the | 325 | /* The Gigabeat S factory partition table contains invalid values for the |