Szerző Téma: idõ átalakitás [debugolás]  (Megtekintve 749 alkalommal)

idõ átalakitás [debugolás]
« Dátum: 2014. Július 01. - 11:58:01 »
0
Sziasztok.
Keresem a hibát a kódba de nem találom :((
10 napot elcsal a kód:
 

stock unix(year,month,day,hour,minute,second)
{
printf(\"%d-%d-%d %d:%d:%d\",year,month,day,hour,minute,second);
new time=0;
new napok = 0;
new days_of_month[12]={31,29,31,30,31,30,31,31,30,31,30,31};
time = second+(minute * 60)+( hour * 3600);
if( ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0) )
{
   days_of_month[1] = 29;
} else {
    days_of_month[1] = 28;
}
if(month > 1) {
for(new i=0; i<month-1;i++)
{
    napok += days_of_month;
}
}
     napok += day;
time += napok*86400;
for(new j=1970;j<year;j++) {
        time += 31536000;
       
         if ( ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
        {
time += 86400;
}
    }
return time;
}

 
És sajnos nem tom hol rontottam el.:(
Meg köszönöm ha valaki segít:)
« Utoljára szerkesztve: 2014. Július 01. - 12:31:36 írta Flash »

Nem elérhető Flash

  • 5726
  • (っ◕‿◕)っ
    • Profil megtekintése
idõ átalakitás [debugolás]
« Válasz #1 Dátum: 2014. Július 01. - 12:31:28 »
0
Ez ugyanaz mint ami neked kell
Unix idõ

idõ átalakitás [debugolás]
« Válasz #2 Dátum: 2014. Július 01. - 15:41:04 »
0
igen unix rendben megy nekem hibátlan csak
rendes dátumból csinál  unix ot és ott abba csalt 10 napot nem tom miért. és ezzel ellenõrisztem(jó a kód) :
 

stock dateformatum(time)
{
new hour=0, minute=0, second=0,string[128];
new month=0, day=0,year=1970;
new days_of_month[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
 
while(time>31536000)
{
time-=31536000;
if(year %4 == 0 && year %100 != 0 || year %400 == 0)//szökõév
{
time-=86400;
}
year++;
}
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))//szökõév
{
        days_of_month[1] = 29;
}else{
        days_of_month[1] = 28;
}
while(time>86400)
{
time -= 86400;
day++;
if(day == days_of_month[month])
{
day=0;
month++;
}
}
while(time>60)
{
time-=60;
minute++;
if(minute==60)
{
   minute = 0;
   hour++;
}
}
second=time;
    format(string,sizeof string,\"%d-%d-%d || %d:%d:%d\",year,month+1,day+1, hour, minute, second);
return string;
}
[code]
úgy hogy a gond dátumból unix idõ de ahogy nézem a kód jó :((
valaki ?

idõ átalakitás [debugolás]
« Válasz #3 Dátum: 2014. Július 12. - 15:02:23 »
0
sikerült azért köszi:)

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal