0 Members and 1 Guest are viewing this topic.
function time_Timer_New(): word;procedure time_Timer_Delete(const Timer: word);procedure time_Timer_Start(const Timer: word);procedure time_Timer_Pause(const Timer: word);function time_Timer_GetTime(const Timer: word): extended;function time_Span_FromDays(const Time: extended): int64;function time_Span_FromHours(const Time: extended): int64;function time_Span_FromMinutes(const Time: extended): int64;function time_Span_FromSeconds(const Time: extended): int64;function time_Span_FromMilliSeconds(const Time: extended): int64;function time_Span_FromMicroSeconds(const Time: extended): int64;function time_Span_FromPart(const Time: extended; const Part: byte): int64;function time_Span_GetTotalDays(const Time: int64): extended;function time_Span_GetTotalHours(const Time: int64): extended;function time_Span_GetTotalMinutes(const Time: int64): extended;function time_Span_GetTotalSeconds(const Time: int64): extended;function time_Span_GetTotalMilliSeconds(const Time: int64): extended;function time_Span_GetTotalMicroSeconds(const Time: int64): extended;function time_Span_GetTotalPart(const Time: int64; const Part: byte): extended;function time_Span_GetDays(const Time: int64): int64;function time_Span_GetHours(const Time: int64): int64;function time_Span_GetMinutes(const Time: int64): int64;function time_Span_GetSeconds(const Time: int64): int64;function time_Span_GetMilliSeconds(const Time: int64): int64;function time_Span_GetMicroSeconds(const Time: int64): int64;function time_Span_GetPart(const Time: int64; const Part: byte): int64;function time_Span_LabelPart(const Part: byte): string;function time_Span_ToStringOpt(Time: int64; const LowerPartBound, UpperPartBound: byte): string;function time_Span_ToString(const Time: int64): string;
function MonthDays(const Month: byte): byte;begin case (Month) of 1, 3, 5, 7, 9, 11: Result := 31; 4, 6, 8, 10, 12: Result := 30; 2: Result := 28; end;end;function GetTime: cardinal;begin Result := 31536000000 * (StrtoInt(FormatDate('y')) - 2008) + 86400000 * MonthDays(StrtoInt(FormatDate('m'))) * StrtoInt(FormatDate('m')) + 86400000 * StrtoInt(FormatDate('d')) + 3600000 * StrtoInt(FormatDate('h')) + 60000 * StrtoInt(FormatDate('n')) + 1000 * StrtoInt(FormatDate('s')) + StrtoInt(FormatDate('zzz'));end;
type TDateTime=record Year: integer; Month: integer; Day: integer; Hour: integer; Minute: integer; Second: integer;end;...//JDN() - returns Julian Day Number from datefunction JDN(date: TDateTime): integer;begin Result:=(367*date.Year)-7*(date.Year+(date.Month+9)/12)/4-3*((date.Year+(date.Month-9)/7)/100+1)/4+275*date.Month/9+date.Day+1721029;end;//DateDiff() - returns difference between two dates//Date part://year or y - difference of years//month or m - difference of months//day or d - difference of days//hour or h - difference of hours//minute or m - difference of minutes//second or s - difference of secondsfunction DateDiff(datepart: string; date1,date2: TDateTime): integer;varr,days,hours,minutes: integer;d1,d2: TDateTime;begin r:=0; d1:=date1; d2:=date2; if(datepart='year')or(datepart='y')then r:=d2.Year-d1.Year else if(datepart='month')or(datepart='M')then r:=((d2.Year-d1.Year)*12)+(d2.Month-d1.Month) else if(datepart='day')or(datepart='d')then r:=JDN(d2)-JDN(d1) else if(datepart='hour')or(datepart='h')then r:=(JDN(d2)-JDN(d1))*24+(d2.Hour-d1.Hour) else if(datepart='minute')or(datepart='m')then begin days:=JDN(d2)-JDN(d1); hours:=d2.Hour-d1.Hour; r:=(days*1440)+(hours*60)+(d2.Minute-d1.Minute); end else if(datepart='second')or(datepart='s')then begin days:=JDN(d2)-JDN(d1); hours:=d2.Hour-d1.Hour; minutes:=d2.Minute-d1.Minute; r:=(days*86400)+(hours*3600)+(minutes*60)+(d2.Second-d1.Second); end; Result:=r;end;
vard1,d2: TDateTime;d1:=ParseDate(FormatDate('yyyy-MM-dd hh:mm:ss'));WriteLn(DateToStr(d1,'MM/dd/yyyy hh:mm:ss'));d2:=DateAdd('day',10,d1);WriteLn(inttostr(DateDiff('day',d1,d2)));if(CompareDates(d1,d2)=1)then WriteLn('d1>d2')else if(CompareDates(d1,d2)=-1)then WriteLn('d1<d2');