Информационный сервер для программистов: Исходники со всего света. Паскальные исходники со всего света
  Powered by Поисковый сервер Яndex: Найдется ВСЁ!
На Главную Исходники Форум Информер Страны мира
   Дата и Время    >>    dates
   
 
 Dates v1R1 - Julian Date Unit   Charles B. Chapman 02.04.95

Модуль для работы с датами в Юлианском календаре.
These routines helps to work with Julian dates.



5k 
 

Version 1R0 - 1991 03 25 1R1 - 1991 04 09 - corrected several bugs, and - deleted <JulianDa2>, <Da2OfWeek> and <JulianDa2ToDate> - all found to be not completely reliable. These routines all assume that the year (y, y1) value is supplied in a form that includes the century (i.e., in YYYY form). No checking is performed to ensure that a month (m, m1) value is in the range 1..12 or that a day (d, d1) value is in the range 1..28,29,30,31. The FUNCTION ValidDate may be used to check for valid month and day parameters. FUNCTION DayOfYearToDate returns month and day (m, d) both = 0 if the day-of-the-year (nd) is > 366 for a leap-year or > 365 for other years. NOTE: As written, FUNCTION Secs100 requires the presence of a 80x87 co-processor. Its declaration and implementation may be altered to REAL to make use of the floating-point emulation. Because the Gregorian calendar was not implemented in all countries at the same time, these routines are not guaranteed to be valid for all dates. The real utility of these routines is that they will not fail on December 31, 1999 - as will many algorithms used in MIS programs implemented on mainframes. The routines are NOT highly optimized - I have tried to maintain the style of the algorithms presented in the sources I indicate. Any suggestions for algorithmic or code improvements will be gratefully accepted. This implementation is in the public domain - no copyright is claimed. No warranty either express or implied is given as to the correctness of the algorithms or their implementation. Author: Charles B. Chapman, London, Ontario, Canada [74370,516] Thanks to Leonard Erickson who supplied a test suite of values. FUNCTION IsLeap (y : WORD) : BOOLEAN; FUNCTION ValidDate (y, m, d : WORD) : BOOLEAN; FUNCTION ValidDate_Str (Str : string; {DWH} VAR Y, M, D : word; VAR Err_Str : string) : boolean; FUNCTION ValidTime_Str (Str : string; {DWH} VAR H, M, S : word; VAR Err_Str : string) : boolean; FUNCTION DayOfYear (y, m, d : WORD) : WORD; FUNCTION JulianDay (y, m, d : WORD) : LONGINT; FUNCTION JJ_JulianDay (y, m, d : word) : LONGINT; {DWH} FUNCTION DayOfWeek (y, m, d : WORD) : WORD; FUNCTION DayOfWeek_Str (y, m, d : WORD) : String; {DWH} FUNCTION TimeStr (h, m, s, c : WORD) : STRING; FUNCTION TimeStr2 (h, m, s : WORD) : STRING; FUNCTION SIDateStr (y, m, d : WORD; SLen : BYTE; FillCh : CHAR) : STRING; FUNCTION MDYR_Str (y, m, d : WORD): STRING; {DWH} FUNCTION Secs100 (h, m, s, c : WORD) : DOUBLE; PROCEDURE DayOfYearToDate (nd, y : WORD; VAR m, d : WORD); PROCEDURE JulianDayToDate (nd : LONGINT; VAR y, m, d : WORD); PROCEDURE JJ_JulianDayToDate (nd : LONGINT; VAR y, m, d : WORD);{DWH} PROCEDURE DateOfEaster (Yr : WORD; VAR Mo, Da : WORD); PROCEDURE AddDays (y, m, d : WORD; plus : LONGINT; VAR y1, m1, d1 : WORD); FUNCTION Lotus_Date_Str (nd : LONGINT) : string; {DWH} FUNCTION Str_Date_to_Lotus_Date_Format (Date : String; VAR Err_Msg : String): LongInt; {OLC}