home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Black Box 4
/
BlackBox.cdr
/
desktop
/
days10.arj
/
DAYS.DOC
< prev
next >
Wrap
Text File
|
1992-01-22
|
32KB
|
561 lines
"DAYS-CALCULATOR"tm copyright 1991, BRIAN ALLEN KUEHN.
This is a shareware product. If you find it to be of use to
you, then you must pay for it. The cost of this software product
is $12.00 postpaid. Please order from and make checks payable
to:
Brian Allen Kuehn
1524 Upper Spring Bay Road
East Peoria, Illinois 61611
As an inducement (read coercion) to get you to pay for this
program if it is useful to you, I have built in a time delay
between the initial shareware announcement screen and the MAIN
MENU screen. The delay increases each time you invoke the
program until the delay becomes unbearable. At that point,
having found the program to be so valuable, you break down and
send me a check for $12.00. I then mail you a floppy with a
"clean" copy of the program that does away both with the
shareware announcement screen and all delays. When you invoke
the "clean" copy of the program, you are instantly greeted with
the MAIN MENU.
THIS PROGRAM WAS CREATED BECAUSE...
I created this program partially for my own use. I am an
attorney. I concentrate my practice in the areas of worker's
compensation and personal injury. As a part of my everyday work,
I find it necessary to calculate periods of disability. For
instance, one of my clients might be off work between 3/13/1987
and 11/26/1991.
You could get out paper calendars and start writing down day
totals from each month to add up. You could start reciting "30
days hath September, April, June and November..." to figure the
number of days between these two dates. Neither way is
particularly easy or enjoyable.
Casio and Radio Shack used to make calculators which did
date calculations. To the best of my knowledge there are no
longer any hand-held calculators available which do date
calculations. I have looked because for years I made use of
these calculators. The way that disability periods are utilized
in the legal profession makes it handy to express the result in
terms of weeks and parts thereof. That is why I chose to output
the two days-between-dates calculations as both total days and
also as weeks and parts thereof. If anyone feels it would be
beneficial to express the results in any further fashion, please
let me know and I will consider making the necessary changes to
the program.
In addition to days between dates, I am constantly diarying
my calendar for future deadlines. I may go into court on a given
day and be given 90 days in which to file a brief on some issue.
That is why I put the two routines in
that add or subtract a number of days from today's date or from
some other specified date to give you a resulting date.
The last routine was added because people like to play with
dates. You can check and see what day of the week you were born
on or what day of the week some significant event occurred on.
This routine also calculates the sequential day in the calendar
year for the date which you have entered.
USING THE PROGRAM
When you start the program, by typing either "days" or "day
m" at the DOS prompt (followed by a press of the return key), you
will be greeted by the following screen:
"DAYS-CALCULATOR"tm copyright 1991, BRIAN ALLEN KUEHN.
MAIN MENU.
1. Number of days between two dates.
2. Number of days between today and any other date.
3. Today's date plus/minus 'X' number of days.
4. Any date plus/minus 'X' number of days.
5. Day of the week & of the year for a given date.
6. Exit.
YOUR CHOICE PLEASE! _
Enter the number of your choice, between 1 and 6, and press
'RETURN'.
1. Main Menu choice number 1 prompts you to enter two
dates. After you have done this, the number of days between
those two dates will be shown as both days and also as weeks and
parts thereof. Please note that in this as in all of the date
entry routines, you must enter ALL of the digits for the year
portion of the date. A representative screen from option number
1 is as follows:
"DAYS-CALCULATOR"tm copyright 1991, BRIAN ALLEN KUEHN.
Enter one or two digit month: 5
Enter one or two digit day: 11
Enter entire year (ALL DIGITS PLEASE!): 1987
First date = Monday, May 11, 1987.
Enter one or two digit month: 12
Enter one or two digit day: 18
Enter entire year (ALL DIGITS PLEASE!): 1991
Second date = Wednesday, December 18, 1991.
There are 1682 days between dates entered.
There are 240 & 2/7ths weeks between dates entered.
page 2
1. Run the same program again.
2. Return to MAIN MENU.
3. Send INPUT & RESULTS to printer.
4. Copy INPUT & RESULTS to file.
YOUR CHOICE PLEASE! _
2. Main Menu choice number 2 is similar to choice number
one, except that it reads the date from the clock in your
computer and uses the date it finds there as the first of the two
dates. If your computer doesn't have a correctly functioning
clock, this routine will start you with a date that does not
represent the current date. Please check the date given as
"Today's date" when you use this menu option. You will then be
prompted to enter a second date. After you have done this, the
number of days between those two dates will be shown as both days
and also as weeks and parts thereof. Please note that in this as
in all of the date entry routines, you must enter ALL of the
digits for the year portion of the date.
3. Main Menu choice number 3 checks the onboard clock on
your computer for the current date, displays that date, and then
permits you to specify a number of days to add to or subtract
from the current date. It will then tell you what the resulting
date is, after addition or subtraction of the specified number of
days. If your computer doesn't have a correctly functioning
clock, this routine will start you with a date that does not
represent the current date. Please check the date given as
"Today's date" when you use this menu option. A representative
screen from option number 3 is as follows:
"DAYS-CALCULATOR"tm copyright 1991, BRIAN ALLEN KUEHN.
CAUTION: The date given below is the date your computer
claims is today's date. If the date is not correct, then
reset the date using the DOS 'date' command or use the
manual version (option 4) of this program on the Main Menu.
Today's date = Friday, December 20, 1991.
Please enter the number of days which you would like
to add to or subtract from today's date. Please precede
a number to be subtracted with a 'minus' (-) sign. You
do not need to enter a plus sign for a number to be added.
ENTER NUMBER OF DAYS TO ADD/SUBTRACT: 120
Resulting date = Saturday, April 18, 1992.
1. Run the same program again.
2. Return to MAIN MENU.
3. Send INPUT & RESULTS to printer.
4. Copy INPUT & RESULTS to file.
YOUR CHOICE PLEASE! _
page 3
4. Main Menu choice number 4 is similar to choice 3 except
the beginning date is manually entered. After you enter the
first date, you are prompted to enter a number of days to either
add to or subtract from the beginning date. It will then tell
you what the resulting date is, after addition or subtraction of
the specified number of days. Please note that in this as in all
of the date entry routines, you must enter ALL of the digits for
the year portion of the date.
5. Main Menu choice number 5 prompts you to enter a date.
It then tells you what day of the week that date falls on. It
also tells you what the day number for the calendar year is. For
instance, 12/31/1991 is day number 365 (the 365th day) in
calendar year 1991. Please note that in this as in all of the
date entry routines, you must enter ALL of the digits for the
year portion of the date.
Each of the first 5 menu choices, when invoked and
completed, present you with the following submenu:
1. Run the same program again.
2. Return to MAIN MENU.
3. Send INPUT & RESULTS to printer.
4. Copy INPUT & RESULTS to file.
YOUR CHOICE PLEASE! _
Option 1 allows you to run the same routine you just ran
over again, inputting different dates or a different number of
days to add or subtract.
Option 2 sends you back to the main menu where you can chose
a different routine to run or you can EXIT by choosing option 6
from the MAIN MENU.
Option 3 copies the important information (the things shown
in yellow in the color version of the program) to the printer.
If the printer is not turned on, the program will not crash, but
neither will it print anything. When using this option, you need
to make sure that your printer has paper and that it is turned
on. I assumed the use of LPT1 as the printer port when I wrote
this; please let me know if there is a need to code the program
for any other porting.
Option 4 will copy important information (the things shown
in yellow in the color version of the program) to a file which
you will name. Any valid DOS filename is permissible from a
single letter or number to a seven letter filename connected by a
period to a three letter file extension. You must use a little
care as any file name you chose will be used. If there already
exists a file of the same name, it will be overwritten.
page 4
EXITING FROM THE PROGRAM
To exit from the program, return to the MAIN MENU and chose
option 6.
COLOR AND MONOCHROME VERSIONS
The program can be loaded in either color or monochrome. To
load the program in color, at the DOS prompt, type "days" and hit
the enter or return key. To load the program in monochrome, at
the DOS prompt, type "days m" and hit the enter or return key.
Both versions are substantively identical, differing only in
visual appearance. The monochrome version is simply the color
version with the ANSI escape sequences turned off.
COLOR VERSION OF "Days-Calculator".
The color version of the program was done in a simple
fashion by using ANSI escape sequences to change foreground and
background colors and intensities. For these escape sequences to
work, you must have the file "ansi.sys" loaded. If "ansi-sys" is
not loaded, the screen attributes will not be changed, and you
will get what look like garbage characters (the literal output of
the ansi escape sequences) littering the screen and upsetting the
otherwise neat spacing of the menus, input, and output. The
program will still work but it will look funny.
To remedy this, and to make the program work in color, you
need to install the "ansi.sys" file. The "ansi.sys" file is one
of the several DOS files and is either located on your hard drive
already or can be copied from your original DOS disks. You
should copy "ansi.sys" to the ROOT directory of your hard disk
(or to your BOOT disk if you are working from a floppy disk
system). In the alternative, you could have a path set up from
your ROOT directory to the directory containing "ansi.sys".
Once "ansi.sys" is in the ROOT directory, or is available to
the ROOT directory via a path command, it can then be loaded by
means of your "config.sys" file. "Config.sys", or system
configuration, configures or sets up your system every time your
computer is started. You will be either modifying your existing
"config.sys" file or creating one.
Go to your ROOT directory and type "DIR CONFIG.SYS" (RETURN)
to see if you have a "config.sys" file already. If you do, you
can see what is in it with the following command: "TYPE
CONFIG.SYS" (RETURN).
You will need to add the following line to the "config.sys"
file to make "ansi.sys" work: "DEVICE = ANSI.SYS". You can use
any ASCII based word processor or text editor to modify the file
and add the line given above.
You can also create or modify the file directly from the
keyboard by using the "COPY CON:(FILENAME)" command. COPY CON
stands for copy console. The console is the keyboard. What you
are literally telling the computer to do is to copy what you are
typing from the keyboard directly to a file. You start with the
page 5
"COPY CON:(FILENAME)" command (which includes the name of the
file which you are creating. You then type the body of the file,
line by line, and conclude on a new line by typing "CONTROL-Z,
RETURN". "CONTROL-Z" causes the lines you have typed on the
screen to be written to the file you have designated.
For example, to create a new config.sys file, including
"ansi.sys", you could type the following:
copy con:config.sys
files = 20
buffers = 20
device = ansi.sys
CTRL-Z (RETURN)
This would create a new "config.sys" file. You would have
to restart your computer to have the new "config.sys" take
effect.
If you already have a config.sys file, you could use the
TYPE command as describe above to show what is already in it, or
you could use the follow command to copy your existing
"config.sys" file to the printer: COPY CONFIG.SYS PRN (RETURN).
This would print out a copy of your existing "config.sys" file.
You could then use COPY CON:CONFIG.SYS to retype what was already
in your "config.sys" file and to add the line "device =
ansi.sys". Remember, anytime you change your "config.sys" file,
you have to reboot your computer for the changes to take effect.
MONOCHROME VERSION OF "Days-Calculator".
In case you prefer monochrome, or for some reason you are
unable to install "ansi.sys" on your computer, you can always run
the program in the monochrome mode at the DOS prompt by typing
"days m" (return). This runs the program but turns off the ANSI
escape sequences that manipulate the color and intensity changes.
DATE ENTRY VALIDATION
The program has been written to prevent entry of an invalid
date. When an entire date has been entered (month, day, and
year) the date is checked for validity. If you have entered an
invalid date (4/31/1991 for instance - remember, April only has
30 days!) you will be presented with an error message advising
you what it was that you did wrong. You will then be kicked back
to the MAIN MENU where you can begin again.
I learned something that I didn't know while building this
program. Only certain centennial years are leap years. If you
think about it, every centennial year 1900, 2000, 2100, etc.,
falls within the normal four year leap year progression. However
only every fourth centennial year, those evenly divisible by 400,
are leap years. The reason for this is basically the same reason
that we have leap years.
The reason that we have leap years is because the earth
takes a little more than 365 days to make a complete circle
around the sun. In rough terms, it takes 365 and 1/4 days to
page 6
make a complete circuit about the sun. If corrections were not
made for that roughly 1/4 day per year, the seasons would slowly
shift as the Calendar got out of sync with the earth's rotation.
The key to the handling of Centennial leap years is due to the
fact that the 1/4 day is rough and not exact. It actually takes
slightly less than 365 and 1/4 days for the earth to make its
complete circuit of the sun. The Centennial year leap years (and
Centennial year non-leap years) are a further means of adjusting
to keep the Calendar in sync with the seasons. Since it is a
much smaller variance than 1/4 day, this adjustment needs to be
made far less often than the four year leap year adjustment.
HOW THE PROGRAM WORKS
What we use as a daily calendar is a Gregorian calendar (see
historical notes below). Due to the way that Gregorian dates are
expressed, and due to the differing number of days in given
months and in given years, it is not a simple matter to add or
subtract dates or to calculate the number of days between two
Gregorian dates.
Fortunately it is possible to convert a Gregorian date to a
Julian date. Julian dates are sequential day numbers that are
incremented by 1 each day, based upon a starting date centuries
ago. A Julian date can also be converted back to a Gregorian
date. Once you have converted two Gregorian dates to Julian
dates, it is a simple matter to subtract one number from the
other to come up with an integer difference in days between the
two dates. In a similar fashion, once you convert a Gregorian
date to a Julian date, you can easily add or subtract any number
of days to come up with another Julian date which can then be
converted back to a Gregorian date.
Because Gregorian dates are converted to Julian dates, it is
absolutely necessary to include all digits of the Gregorian
calendar year when inputting a date. It would be possible to
write the program to require entry of only the last two digits of
the year (assuming the first two digits to be 19__). This would
however limit the utility of the program to a single century. By
requiring entry of all digits for the year, it makes the
program's scope almost limitless. It will go almost forever into
the future (until you exceed the ability of the "C" language in
its ability to handle a long integer value which might well take
us past the end of mankind). It can only go back in time to the
year A.D. (Anno Domini) zero as it has not been programmed to
deal with negative year numbers. This could be done but I didn't
see any practical application for it. If someone can suggest a
practical application, I would consider adding in the capability
to deal with negative Gregorian year numbers.
page 7
HISTORICAL NOTES ON CALENDARS
(from Grolier's Electronic Encyclopedia)
Ancient Calendars
The earliest complete calendars were probably based on lunar
observations. The Moon's phases occur over an easily observed
interval, the month; religious authorities declared a month to
have begun when they first saw the new crescent Moon. During
cloudy weather, when it was impossible to see the Moon, the
beginning of the month was determined by calculation. The
interval from new moon to new moon, called a synodic month, is
about 29.53 days. Hence, calendar months contained either 29 or
30 days. Twelve lunar months, which total 354.36 days, form a
lunar year, almost 11 days shorter than a tropical year.
A lunar year is not suitable for agricultural purposes. To
keep in step with the Sun, lunar-solar calendars were formed by
adding an additional (leap) month when the observation of crops
made it seem necessary. Hundreds of such calendars, with
variations, were formed at various times in such different areas
as Mesopotamia, Greece, Rome, India, and China. The month was not
always based on the phases of the Moon; the Mayan calendar
divided the year into 18
20-day months, with a 5-day period at the end. Romans, during
the late republic, used various lunar-solar calendars. These
calendars were supposedly based only on observation, but in fact
they were influenced by political considerations. The Roman
calendar was in error by several months during the reign of
Julius Caesar, who recognized the need for a stable, predictable
calendar and formed one with the help of an astronomer,
Sosigenes. The year 46 BC was given 445 days, to compensate for
past errors, and every common year thereafter was to have 365
days. Every fourth year, starting with 45 BC, was to be
designated a leap year of 366 days, during which February, which
commonly had 28 days, was extended by one day. The rule was not
correctly applied, but the calendar was corrected by Augustus
Caesar by AD 8.
Gregorian Calendar
The Julian leap-year rule created 3 leap years too many in
every period of 385 years. As a result, the actual occurrence of
the equinoxes and solstices drifted away from their assigned
calendar dates. As the date of the spring equinox determines that
of Easter, the church was concerned, and Pope Gregory XIII, with
the help of an astronomer, Christopher Clavius (1537-1612),
introduced what is now called the Gregorian calendar. Wednesday,
Oct. 4, 1582 (Julian), was followed by Thursday, Oct. 15, 1582
(Gregorian); leap years occur in years exactly divisible by four,
except that years ending in 00 must be divisible by 400 to be
leap years. Thus, 1600, 1984, and 2000 are leap years, but 1800
and 1900 are not.
page 8
The Gregorian civil calendar is a solar calendar, calculated
without reference to the Moon. However, the Gregorian calendar
also includes rules for determining the date of Easter and other
religious holidays, which are based on both the Sun and the Moon.
The Gregorian calendar was quickly adopted by Roman Catholic
countries. Other countries adopted it later, sometimes choosing
only the civil part. It was not adopted by the Soviet Union until
1918; Turkey did not adopt it until 1927.
Year Beginning
The year used to begin at different times in different
localities. The Roman year began in March; December, whose name
is derived from the Latin word for "ten," was the tenth month of
the year. In 153 BC, Roman consuls began taking office on January
1, which became the beginning of the year. This practice was
retained in the Julian and Gregorian calendars, although other
starting dates continued to be used; England and its colonies,
for example, used March 25 and the Julian reckoning until 1752.
Thus, George Washington was officially born on Feb. 11, 1731, Old
Style (O.S.); this is Feb. 22, 1732, Gregorian, or New Style
(N.S.).
Week
The Babylonians used a nonastronomical, 7-day interval, the
week, which was adopted by the Jews. The seventh day, the
Sabbath, was given a religious significance. Independently, the
Romans associated a cycle of 7 days with the Sun, the Moon, and
the five known planets. Their names became attached to the days
of the week: Sunday (dies solis, "Sun's day"), Monday (dies
lunae, "
Moon's day"), and Saturday (dies Saturni, "Saturn's day") retain
their names derived directly from the Roman culture, and Tuesday
("Tiw's day"), Wednesday ("Woden's day"), Thursday ("Thor's
day"), and Friday ("Frigg's day") are derived from the Germanic
equivalents of Mars, Mercury, Jupiter, and Venus, respectively.
Year
In ancient calendars, years were generally numbered
according to the year of a ruler's reign. About AD 525, a monk
named Dionysius Exiguus suggested that years be counted from the
birth of Christ, which was designated AD (anno Domini, "the year
of the Lord") 1. This proposal came to be adopted throughout
Christendom during the next 500 years.^ The year before AD 1 is
designated 1 BC (before Christ). Dionysius had referred the year
of Christ's birth to other eras. Modern chronology, however,
places the event at about 4 BC.
The 1st century of the Christian Era began in AD 1, the 2d
in AD 101; the 21st will begin in 2001.
page 9
THE NAMES OF THE MONTHS
January: named for Janus, protector of doorways.
February: named for Februalia, a time period when sacrifices
were made to atone for sins.
March: named for Mars, the god of war, presumably signifying
that the campaigns interrupted by the winter could be
resumed.
April: from aperire, Latin for "to open" (buds).
May: named for Maia, the goddess of growth of plants.
June: from juvenis, Latin for "youth".
July: named for Julius Caesar.
August: named for Augustus, the first Roman emperor.
September: from septem, Latin for "seven".
October: from octo, Latin for "eight".
November: from novem, Latin for "nine".
December: from decem, Latin for "ten".
NOTE: The earliest Latin calendar was a 10-month one; thus
September was the seventh month, October, the eighth, etc. July
was originally called Quintilis, as the fifth month; August was
originally called Sextilis, as the sixth month.
Bibliography: Archer, Peter, The Christian Calendar and the
Gregorian Reform (1941); Asimov, Isaac, The Clock We Live On
(1963); Keane, Jerryl, Book of Calendars (1981); Philips,
Alexander, The Calendar: Its History, Structure, and Improvement
(1921); Watkins, Harold, Time Counts: The Story of the Calendar
(1954); Wilson, P. W., The Romance of the Calendar (1937).
COMMENTS, SUGGESTIONS, AND COMPLAINTS
I have been teaching myself the "C" programming language and
this program is my first attempt to use "C". It is more compact
and elegant than QuickBasic which is what I have primarily used
in the past. Please address any comments, suggestions, or
complaints to the program author at the following address:
Brian Allen Kuehn
1524 Upper Spring Bay Road
East Peoria, Illinois 61611
page 10
ORDER FORM
Brian Allen Kuehn
1524 Upper Spring Bay Road
East Peoria, Illinois 61611
I enclose my personal check, cashiers check, or money order
for $12.00, made payable to Brian Allen Kuehn.
Please send my registered copy of "DAYS-CALCULATOR"tm to:
_____________________________________
Name
_____________________________________
Street Address
_____________________________________
City, State, Zip
_____________________________________
Phone (optional)
I understand that I will receive a 5.25" disk with a clean
copy of the program. My name will be added to the customer list
for notification regarding any updates to "DAYS-CALCULATOR"tm. I
will be assigned my own unique serial number: example -
#27135008713.