home *** CD-ROM | disk | FTP | other *** search
- {*********************************************************}
- {* ESUTIL.PAS 1.05 *}
- {* Copyright (c) 1997-98 TurboPower Software Co *}
- {* All rights reserved. *}
- {*********************************************************}
-
- {$I ES.INC}
-
- {$B-} {Complete Boolean Evaluation}
- {$I+} {Input/Output-Checking}
- {$P+} {Open Parameters}
- {$T-} {Typed @ Operator}
- {$W-} {Windows Stack Frame}
- {$X+} {Extended Syntax}
-
- {$IFNDEF Win32}
- {$G+} {286 Instructions}
- {$N+} {Numeric Coprocessor}
- {$C MOVEABLE,DEMANDLOAD,DISCARDABLE}
- {$ENDIF}
-
- unit EsUtil;
- {-general utility routines}
-
- interface
-
- uses
- {$IFDEF Win32} Windows, {$ELSE} WinTypes, WinProcs, {$ENDIF}
- Graphics, SysUtils, SRMgr;
-
- function DaysInMonth(Year, Month : Integer) : Integer;
- {-return the number of days in the specified month of a given year}
- function DefaultEpoch : Integer;
- {-return the current century}
- function GetLeftButton : Byte;
- procedure GetRGB(Clr : TColor; var IR, IG, IB : Byte);
- function IsLeapYear(Year : Integer) : Boolean;
- {-return True if Year is a leap year}
- function Max(I, J : Integer) : Integer;
- function Min(I, J : Integer) : Integer;
-
- var
- StrRes : TpsStringResource;
-
- implementation
-
-
- function DaysInMonth(Year, Month : Integer) : Integer;
- var
- Cent : Integer;
- Y : Word;
- M : Word;
- D : Word;
- begin
- case Month of
- 1, 3, 5, 7, 8, 10, 12 :
- Result := 31;
- 4, 6, 9, 11 :
- Result := 30;
- 2 : begin
- if Year < 100 then begin
- DecodeDate(SysUtils.Date, Y, M, D);
- Cent := (Y div 100) * 100;
- Year := Year + Cent;
- end;
- Result := 28+Ord(IsLeapYear(Year));
- end;
- else
- Result := 0;
- end;
- end;
-
- function DefaultEpoch : Integer;
- var
- ThisYear : Word;
- ThisMonth : Word;
- ThisDay : Word;
- begin
- DecodeDate(SysUtils.Date, ThisYear, ThisMonth, ThisDay);
- Result := (ThisYear mod 100) * 100; {!!.05}
- end;
-
- function GetLeftButton : Byte;
- const
- RLButton : array[Boolean] of Word = (VK_LBUTTON, VK_RBUTTON);
- begin
- Result := RLButton[GetSystemMetrics(SM_SWAPBUTTON) <> 0];
- end;
-
- procedure GetRGB(Clr : TColor; var IR, IG, IB : Byte);
- begin
- IR := GetRValue(Clr);
- IG := GetGValue(Clr);
- IB := GetBValue(Clr);
- end;
-
- function IsLeapYear(Year : Integer) : Boolean;
- begin
- Result := (Year mod 4 = 0) and (Year mod 4000 <> 0) and
- ((Year mod 100 <> 0) or (Year mod 400 = 0));
- end;
-
- function Max(I, J : Integer) : Integer;
- begin
- if I > J then
- Result := I
- else
- Result := J;
- end;
-
- function Min(I, J : Integer) : Integer;
- begin
- if I < J then
- Result := I
- else
- Result := J;
- end;
-
- procedure FreeStrRes; far;
- begin
- StrRes.Free;
- StrRes := nil;
- end;
-
- initialization
- StrRes := TpsStringResource.Create(HInstance, 'ESSENTIALS_STRINGS_ENGLISH');
-
- {$IFDEF Win32}
- finalization
- FreeStrRes;
- {$ELSE}
- AddExitProc(FreeStrRes);
- {$ENDIF}
- end.