|
A set of classes for efficient and convenient handling of dates and times
especially in an airline environment.
First, the License. As the author of this code, I place it under the
MIT License, reproduced below:
|
Copyright (c) 2002 Carl Smotricz
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
The rationale for this package is to provide efficient representations of dates
and times with which to replace java.util.Date and
java.util.GregorianCalendar for some specialized applications
which don't need the full power of these types. In particular, managing time
in scalar variables may often avoid the use of objects, whose construction
tends to waste a lot of time in a Java program.
It contains reasonably optimized routines for interconverting between the
following formats:
- "Human-manageable" formats:
- Hours and minutes (HM):
-
- A time in the 24 hour day, in the form of separate integral values for
hours and minutes;
- Year, month, day (YMD):
- Gregorian (normal) date in the form of separate integral values for year,
month and day;
- Year, month, day, hours, minutes (YMDHM):
- Years, months, days, hours and minutes as five integral values.
- Binary formats, encoding the above in a single integer:
- Minutes Since Midnight (MSM):
- What the name says.
Midnight is 0, the minute before next midnight is 1439. This format is widely
used in USAS applications, because flight times are in minutes.
- QDate (QD):
- The number of days since 1900-01-01.
I apologize for inventing yet another date format, but this one seems best suited
for dealing with dates both in the last century and in the next few to come.
I found UNIX's starting point in 1970 to be unnecessarily restrictive.
- QDateTime (QDT):
- The number of minutes since midnight, 1900-01-01.
This is essentially a (1440 * QuickDate) + MSM.
It's useful for doing date and time arithmetic with granularity down to the
minute, while extending from 1900 to the next 4 milennia.
- Freq:
- Operating days, as a bitmap stored in an int. Values 64, 32, 16, 8, 4, 2 and 1
represent Monday through Sunday, respectively, which means that any combination of
operating days will "fit" into a number between 1 and 127. Bitmaps are very effective
for some forms of binary arithmetic.
|