summaryrefslogtreecommitdiff
path: root/firmware/usbstack/usb_storage.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/usbstack/usb_storage.c')
-rw-r--r--firmware/usbstack/usb_storage.c25
1 files changed, 25 insertions, 0 deletions
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
298static 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