Dec 122017
 
Accurate manipulation of dates with Turbo Pascal 4.0.
File DATEPAK4.ZIP from The Programmer’s Corner in
Category Pascal Source Code
Accurate manipulation of dates with Turbo Pascal 4.0.
File Name File Size Zip Size Zip Type
DATEPAK4.DOC 5120 1614 deflated
DATEPAK4.PAS 2992 774 deflated
DATEPAK4.TPU 1744 797 deflated

Download File DATEPAK4.ZIP Here

Contents of the DATEPAK4.DOC file





DATEPAK4
========

DATEPAK4 is a set of procedures intended to simplify the accurate
manipulation of dates. These procedures are based on Algorithm
#398 and associated comments, from the Collected Algorithms of
the ACM.

Originally distributed as DATEPACK for TURBO/PASCAL ver. 3 (and
compatible with ver. 4), the routines relied heavily on Real
arithmetic. Re-written here for ver. 4, all Real arithmetic has
been replaced by LongInt. This results in a speed-up of nearly
60%, over the original DATEPACK routines compiled with ver. 4.
Because no real-type or Comp arithmetic is used in DATEPAK4, the
active or passive, without modification or recompilation.


Author: W.G. Madison
W.G. Madison and Associates, Ltd.
P.O. Box 898
Greenbelt, MD 20770-0898
(CompuServe 73240,342)

Date: November 1987


Before proceeding, several definitions are necessary to provide
the framework for understanding the various conversions possible
through the use of the DATEPAK4 procedures.


GREGORIAN DATE

is the date system commonly used in modern western
nations. Established by Papal bull in March 1582, it
adjusted the calendar in use up to that time in order to
restore the vernal equinox to March 21. This was accomp-
lished by suppressing the dates from the 5th through the
14th (inclusive) of October, 1582. While the Gregorian
calendar was accepted quickly throughout most of Europe,
it was not adopted in England and the Colonies until
1752. When YEAR, MONTH, and/or DAY are passed or return-
ed as parameters in the DATEPAK4 procedures, the Gre-
gorian system is assumed.


JULIAN DAY-NUMBER, or JULIAN DAY

is the representation of a given date as its serial
index, beginning on January 1, 4713 B.C. The date chosen
as the basis has astronomical significance, and is wide-
ly recognized in the scientific community. Proposed by
the astronomer Joseph Scaliger, it is named in memory of
his father and not, as often assumed, for Julius Caesar.
When used as a parameter by any of the DATEPAK4 rou-


1



tines, it will be passed as a LongInt representation of
a 7 digit integer.


JULIAN DATE

is the representation of a given date as its serial
index, taking January 1st of the given year as the base
(=1). When used as a parameter by any of the DATEPAK4
procedures, both the serial index and the year will be
represented as simple integers. (By the way, this one
was named for Julius Caesar).


SMITHSONIAN DATE

is the representation of a given date as its serial
index, with November 18, 1858 as the base (=1). While
procedures are not included for converting from or to
the Smithsonian date, it is readily calculated from the
Julian Day as

Smithsonian = Julian - 2400001


































2



The following procedures are included in DATEPAK4.

GregorianToJulianDN(Year, Month, Day : Integer;
var JulianDN : LongInt);

computes the Julian Day-Number from the Gregorian date.


*********************

JulianDNToGregorian(JulianDN : LongInt;
var Year, Month, Day : Integer);

computes the Gregorian date from the Julian Day-Number.


*********************

GregorianToJulianDate(Year, Month, Day : Integer;
var JulianDate : Integer);

computes the Julian date from the Gregorian date.


*********************

JulianToGregorianDate(JulianDate, Year : Integer;
var Month, Day : Integer);

computes the Gregorian date from the Julian date.


*********************

DayOfWeek(Year, Month, Day : Integer; var DayOfWeek : Integer);

computes the day of the week (Sunday = 1; Saturday = 7) from
the Gregorian date.



















3


 December 12, 2017  Add comments

Leave a Reply