$if 0 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ· PowerBASIC v3.20 ÚÄÄ´ DASoft ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ· ³ ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ Copyright 1995 ³ DATE: 1995-10-01 ÇÄ· ³ ³ FILE NAME DATES .TXT º by ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄ º º ³ ³ º Don Schullian, Jr. º º ³ ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º º ³ A license is hereby granted to the holder to use this source code in º º ³ any program, commercial or otherwise, without receiving the express º º ³ permission of the copyright holder and without paying any royalties, º º ³ as long as this code is not distributed in any compilable format. º º ³ IE: source code files, PowerBASIC Unit files, and printed listings º º ÔÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º ³ .................................... º ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ $endif For most business and personal applications nothing that happened before Jan. 1, 1872 and nothing that is going to happen after Dec. 31, 2050 has any importance, so, this extremely fast and efficient method of packing dates into 2byte WORDs is just what the doctor ordered! Storing dates has always been a memory hungry process! In years past we could store just the last 2 numbers and assume the 19. But, as the 21st century looms large upon the horizon we no longer have that luxury. This system solves both the problem of byte hungry storage and spanning the 2 centuries. Also, when the date has been reduced to a number it is quite simple to compute things like: ages, elapsed time, future payment dates, etc. You can also simply convert from one display style to another, or even run a quick check on the validity of an input date string. With the advent of international BBSing the speed of software dispersal has become a matter of everyday life. A program you put up in California today will be in Europe the next! Because there are three different ways to display a date (not counting for separating characters) your programs should be able to "switch gears" at a moments notice. This system allows this to happen with almost NO extra coding on your part and is very easy to maintain as you will always be working with WORDs and numbers and not a 10byte string. 01\31\1994 American Style DD\MM\YYYY 31.01.1994 European Style MM.DD.YYYY 1994-01-31 Japanese Style YYYY-MM-DD The user's preference for date styles can be found in his/her system so it is a very simple matter to provide what is wanted for each and every user, or offer them a choice, even if they change there minds every day! Some things to remember about dates when you are doing your math: 1) Leap year is a year that is: DIVISIBLE BY 4 but NOT DIVISIBLE BY 100 unless DIVISIBLE BY 400 ie: 1800 wasn't a leap year BUT 2000 is a leap year! 2) Work in units of 4 years: 1461 days 3) Jan. 1, 1872 was a Monday ie: DayOfTheWeek? = ( PackedDate?? MOD 7 ) 4) when converting from one display style to another first convert the string to a number, then change the style setting, and finally do the conversion. Don't attempt a string to string conversion as it is too costly in time and code. DOS stores dates in a WORD also but it is quite a different style than the one described above. This system works on dates after Dec.31, 1980 and is not capable of math functions, etc. In other words, it is NOT as handy as our system but has been included here because the routines to implement this system were, for the large part, required to convert the system's date for our system. In the event some unsupported display type is required by your program there are sufficient routines included in this library to allow you to quickly create your own functions. NOTE: this whole system is geared to the 10 character date string. It is capable of returning an 8 character string but will convert it back into Y??, M?, D? using the system's century.