home *** CD-ROM | disk | FTP | other *** search
- unit Globals;
-
- interface
-
- const pi = 3.1415926535897932385;
-
- {$IFOPT N+}
- type Float = Extended;
- {$ELSE}
- type Float = Real;
- {$ENDIF}
-
- function Tan(x:float):float;
-
- function Radians(degrees:Float):Float;
-
- function Sex2Dec(hh:longint;mm,ss:integer):Float;
-
- procedure Dec2Sex(dec:float; var hh:longint; var mm,ss:integer);
-
-
- function LeapYear(y:longint):Boolean;
-
- function DaysIn(y:longint;m:integer):Integer;
-
- function ValidDate(y:LongInt;m,d:integer):boolean;
-
- function DayOfYear(y:longint;m,d:integer):integer;
-
-
- implementation
-
-
- function Tan(x:float):float;
- begin
- Tan := sin(x) / cos(x);
- end;
-
- function Radians(degrees:Float):Float;
- begin
- Radians := degrees * 2*pi / 360.0;
- end;
-
- function Sex2Dec(hh:longint;mm,ss:integer):Float;
- var dec : Float;
- begin
- dec := abs(hh)+(abs(mm)+(abs(ss)/60.0))/60.0;
- if hh<0 then dec := -dec;
- Sex2Dec := dec;
- end;
-
- procedure Dec2Sex(dec:float; var hh:longint; var mm,ss:integer);
- begin
- hh := trunc(dec);
- mm := trunc((dec - hh) * 60);
- ss := trunc(((dec - hh) * 60 - mm) * 60 + 0.5);
- end;
-
-
- function LeapYear(y:longint):Boolean;
- begin
- LeapYear := (y div 4 = 0) and not(y div 100 = 0) or (y div 400 = 0);
- end;
-
- function DaysIn(y:longint;m:integer):Integer;
- begin
- if (m<1) or (m>12) then
- DaysIn := 0
- else if m IN [4,6,9,11] then
- DaysIn := 30
- else if m=2 then begin
- if LeapYear(y) then
- DaysIn := 29
- else
- DaysIn := 28
- end
- else
- DaysIn := 31;
- end;
-
- function ValidDate(y:LongInt;m,d:integer):boolean;
- var days : integer;
- begin
- days := DaysIn(y,m);
- ValidDate := (days>=d) and (days>0);
- end;
-
- function DayOfYear(y:longint;m,d:integer):integer;
- var i: integer;
- begin
- for i := 1 to m-1 do
- d := d + DaysIn(y,i);
- DayOfYear := d;
- end;
-
- end.