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:)
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 ?