{$D-} Unit Time; interface {***************************************************************************} {***************************************************************************} Function DateTimeStrNow: string; Function DateTimeStr(Year, Month, Day, DayOfWeek, Hour, Minute, Second, Sec100: word): string; Function JulianDateTime(InJulianDateWithoutTime: longint; InTimeWithoutDateInSecs: real): longint; Function JulianDateTimeNow: longint; Function JulianDateWithoutTime(Year, Month, Day: word): longint; Function JulianDateWithoutTimeNow: longint; Function TimeWithoutDateInSecs(Hour, Min, Sec, Sec100: word): real; Function TimeWithoutDateInSecsNow: real; Function SecsMerge(Day, Hour, Min, Secs: longint): longint; Procedure SecsSplit(NumSecs: longint; var Days, Hours, Minutes, Seconds: longint); implementation {***************************************************************************} {***************************************************************************} uses Dos, Glob, Data; Function DateTimeStrNow: string; {***************************************************************************} var Year, Month, Day, DayOfWeek, Hour, Minute, Second, Sec100: word; Temp: string; begin GetDate(Year, Month, Day, DayOfWeek); GetTime(Hour, Minute, Second, Sec100); Temp := DateTimeStr(Year, Month, Day, DayOfWeek, Hour, Minute, Second, Sec100); DateTimeStrNow := Temp; end; Function DateTimeStr(Year, Month, Day, DayOfWeek, Hour, Minute, Second, Sec100: word): string; {***************************************************************************} var MonthStr, DayOfWeekStr: string; Temp: string; begin case Month of 1: MonthStr := 'JAN'; 2: MonthStr := 'FEB'; 3: MonthStr := 'MAR'; 4: MonthStr := 'APR'; 5: MonthStr := 'MAY'; 6: MonthStr := 'JUN'; 7: MonthStr := 'JUL'; 8: MonthStr := 'AUG'; 9: MonthStr := 'SEP'; 10: MonthStr := 'OCT'; 11: MonthStr := 'NOV'; 12: MonthStr := 'DEC'; end; {case} case DayOfWeek of 0: DayOfWeekStr := 'SUN'; 1: DayOfWeekStr := 'MON'; 2: DayOfWeekStr := 'TUE'; 3: DayOfWeekStr := 'WED'; 4: DayOfWeekStr := 'THU'; 5: DayOfWeekStr := 'FRI'; 6: DayOfWeekStr := 'SAT'; end; {case} Temp := StrIntZer(Year, 4) + ' ' + MonthStr + ' ' + StrIntZer(Day,2) + ' ' + DayOfWeekStr + ' ' + StrIntZer(Hour, 2) + ':' + StrIntZer(Minute, 2) + ':' + StrIntZer(Second, 2) + '.' + StrIntZer(Sec100, 2); DateTimeStr := Temp; end; Function JulianDateTime(InJulianDateWithoutTime: longint; InTimeWithoutDateInSecs: real): longint; {***************************************************************************} var Temp: longint; begin Temp := InJulianDateWithoutTime * 24 * 60 * 60; Temp := Temp + trunc(InTimeWithoutDateInSecs); JulianDateTime := Temp; end; Function JulianDateTimeNow: longint; {***************************************************************************} var Temp: longint; begin Temp := JulianDateTime(JulianDateWithoutTimeNow, TimeWithoutDateInSecsNow); JulianDateTimeNow := Temp; end; Function JulianDateWithoutTime(Year, Month, Day: word): longint; {***************************************************************************} {* p. 528 TP Programmer's Toolkit {***************************************************************************} var Temp: longint; begin if Year < 100 then Year := Year + 1900; Temp := (Month-14) div 12; Temp := Day - 32075 + (1461*(Year+4800+Temp) div 4) + (367*(Month-2-Temp*12) div 12) - (3*((Year+4900+Temp) div 100) div 4); JulianDateWithoutTime := Temp; end; Function JulianDateWithoutTimeNow: longint; {***************************************************************************} var Temp: longint; Year, Month, Day: word; begin GetDate(Year, Month, Day, DumWord); Temp := JulianDateWithoutTime(Year, Month, Day); JulianDateWithoutTimeNow := Temp; end; Function TimeWithoutDateInSecs(Hour, Min, Sec, Sec100: word): real; {***************************************************************************} var HourL, MinL, SecL, Sec100L: real; Temp: real; begin HourL := Hour; MinL := Min; SecL := Sec; Sec100L := Sec100; Temp := HourL*3600 + MinL*60 + SecL + Sec100L/100; TimeWithoutDateInSecs := Temp; end; Function TimeWithoutDateInSecsNow: real; {***************************************************************************} var Hour, Min, Sec, Sec100: word; Temp: real; begin GetTime(Hour, Min, Sec, Sec100); Temp := TimeWithoutDateInSecs(Hour, Min, Sec, Sec100); TimeWithoutDateInSecsNow := Temp; end; Function SecsMerge(Day, Hour, Min, Secs: longint): longint; {***************************************************************************} var Temp: longint; begin Temp := Secs; Temp := Temp + Min*60; Temp := Temp + Hour*3600; Temp := Temp + Day*86400; SecsMerge := Temp; end; Procedure SecsSplit(NumSecs: longint; var Days, Hours, Minutes, Seconds: longint); {***************************************************************************} begin Days := NumSecs div 86400; Hours := (NumSecs mod 86400) div 3600; Minutes := ((NumSecs mod 86400) mod 3600) div 60; Seconds := ((NumSecs mod 86400) mod 3600) mod 60; end; {***************************************************************************} {***************************************************************************} {***************************************************************************} begin end.