т.е мне нужна программа которая будет считать дни с 14.11.2008 г по настоящее время сколько дней прошло и т.д.... помогите кому не сложно...
Реализация на TP (код не мой, нашел давно где то в инете) Code: program data; uses crt; label escape,asd,dsa,contin; var m1:array[1..12] of integer; m2:array[1..12] of integer; a:array[1..3] of longint; b:array[1..3] of longint; err:boolean; cd:char; i:byte; razn,d1,d2,mo1,mo2,y1,y2:longint; begin clrscr; writeln('Input first date'); writeln('Day'); read(a[1]); writeln('Month'); read(a[2]); writeln('Year'); read(a[3]); writeln('Input second date'); writeln('Day'); read(b[1]); writeln('Month'); read(b[2]); writeln('Year'); read(b[3]); for i:=1 to 12 do begin if (i=1) or (i=3) or (i=5) or (i=7) or (i=8) or (i=10) or (i=12) then begin m1[i]:=31; m2[i]:=31; end else begin m1[i]:=30; m2[i]:=30; end; end; if a[3]/4=int(a[3]/4) then m1[2]:=29 else m1[2]:=28; if b[3]/4=int(b[3]/4) then m2[2]:=29 else m2[2]:=28; clrscr; if (a[1]<=0) or (b[1]<=0) or (a[2]<=0) or (b[2]<=0) or (a[3]<=0) or (b[3]<=0) then err:=true; if (a[2]>12) or (b[2]>12) then err:=true; if a[1]>m1[a[2]] then err:=true; if b[1]>m2[b[2]] then err:=true; if err=true then begin writeln('Error! Please check your data.'); goto escape; end; if a[3]>b[3] then dsa: begin d1:=a[1]; mo1:=a[2]; y1:=a[3]; d2:=b[1]; mo2:=b[2]; y2:=b[3]; goto contin; end; if b[3]>a[3] then asd: begin d1:=b[1]; d2:=a[1]; mo1:=b[2]; mo2:=a[2]; y1:=b[3]; y2:=a[3]; goto contin; end; if b[3]=a[3] then begin if a[2]>b[2] then goto dsa; if b[2]>a[2] then goto asd; if b[2]=a[2] then begin if a[1]>b[1] then goto dsa; if a[1]<b[1] then goto asd; end; end; contin: razn:=0; repeat if y2/4=int(y2/4) then m1[2]:=29 else m1[2]:=28; razn:=razn+1; if (d2<=m1[mo2]) and (mo2<=12) then d2:=d2+1; if (d2>m1[mo2]) and (mo2<12) then begin mo2:=mo2+1; d2:=1; end; if (d2>m1[mo2]) and (mo2=12) then begin y2:=y2+1; d2:=1; mo2:=1; end; until (d1=d2) and (mo1=mo2) and (y1=y2); escape: writeln('Difference'); writeln(razn); writeln('days'); cd:=readkey; end. Скачать P.S. Самому писать к сожалению времени нет.
Если на Delphi, то есть функция DaysBetween: http://www.delphisources.ru/pages/faq/faq_delphi_basics/DaysBetween.php.html
Code: FILETIME orig; // берем текущее время (100 наносекундных интервалов с 1 янв 1601г) GetSystemTimeAsFileTime(&orig); SYSTEMTIME st_2008; FILETIME ft_2008; st_2008.wYear = 2008; st_2008.wMonth = 11; st_2008.wDay = 14; st_2008.wHour = 0; st_2008.wMinute = 0; st_2008.wSecond =0; st_2008.wMilliseconds = 0; // берем скока 100 наносекундных интервалов с 11 14 2008г) SystemTimeToFileTime(&st_2008, &ft_2008); ULONG totalseconds, totalminutes, totalhours, totaldays, totalyears; ULONG seconds1, seconds2; // конвертим в число секунд с 1970года RtlTimeToSecondsSince1970((PLARGE_INTEGER)&orig, &seconds1); RtlTimeToSecondsSince1970((PLARGE_INTEGER)&ft_2008, &seconds2); // во и терь получаем разницу в секундах между сейчас и 11.14.2008 totalseconds = seconds1 - seconds2; // и делим чтоб получить часы дни и годы totalminutes = totalseconds / 60; totalhours = totalminutes / 60; totaldays = totalhours / 24; totalyears = totaldays / 365; // печатаем dprintf("С 11.14.2008 прошло: %d секунд или %d минут или %d часов или %d дней или %d лет", totalseconds, totalminutes, totalhours, totaldays, totalyears); // чтобы выводить можно использовать double // а чтобы точно (не или или) х дней х часов - дели по модулю
ели у тя не видит RtlTimeTo... то повыше добавь void (__stdcall *RtlTimeToSecondsSince1970)(PLARGE_INTEGER, PULONG); (FARPROC&)RtlTimeToSecondsSince1970 = GetProcAddress(GetModuleHandle("ntdll.dll"), "RtlTimeToSecondsSince1970");