mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
simplify yearday_to_daymonth()
This commit is contained in:
parent
803408f186
commit
dd57c01bef
1 changed files with 8 additions and 19 deletions
|
@ -333,25 +333,15 @@ static enum {
|
||||||
#if CONFIG_RTC
|
#if CONFIG_RTC
|
||||||
static void yearday_to_daymonth(int yd, int y, int *d, int *m)
|
static void yearday_to_daymonth(int yd, int y, int *d, int *m)
|
||||||
{
|
{
|
||||||
static const char tnl[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
static char t[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||||
static const char tl[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
|
||||||
const char *t;
|
|
||||||
int i=0;
|
|
||||||
|
|
||||||
if((y%4 == 0 && y%100 != 0) || y%400 == 0)
|
bool leap = (y%4 == 0 && y%100 != 0) || y%400 == 0;
|
||||||
{
|
t[2] = leap ? 29 : 28;
|
||||||
t=tl;
|
|
||||||
}
|
int i;
|
||||||
else
|
for (i = 0; i < 12 && yd >= t[i]; i++)
|
||||||
{
|
yd -= t[i];
|
||||||
t=tnl;
|
|
||||||
}
|
|
||||||
|
|
||||||
while(i<12 && yd >= t[i])
|
|
||||||
{
|
|
||||||
yd-=t[i];
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
*d = yd+1;
|
*d = yd+1;
|
||||||
*m = i;
|
*m = i;
|
||||||
}
|
}
|
||||||
|
@ -757,8 +747,7 @@ static void handle_scsi(struct command_block_wrapper* cbw)
|
||||||
|
|
||||||
struct storage_info info;
|
struct storage_info info;
|
||||||
unsigned int length = cbw->data_transfer_length;
|
unsigned int length = cbw->data_transfer_length;
|
||||||
unsigned int block_size = 0;
|
unsigned int block_size, block_count;
|
||||||
unsigned int block_count = 0;
|
|
||||||
bool lun_present=true;
|
bool lun_present=true;
|
||||||
unsigned char lun = cbw->lun;
|
unsigned char lun = cbw->lun;
|
||||||
unsigned int block_size_mult = 1;
|
unsigned int block_size_mult = 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue