[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
New Calendar modules
A new set of Calendar modules have been uploaded to the cognac site at
/pub/ooc/incoming/lib. They also require the Locale.Mod module which
will be uploaded separately.
Here is the readme file accompanying this release:
I've included a simple demonstration program called Cal which duplicates most of
the functionality of the UNIX cal utility. It shows how many of the date/time
functions operate in a practical application and might be able to better answer
any questions about how to interface to the modules shown below. If you happen
to try the following: "Cal 9 1752" the resulting month IS NOT a mistake but is
a result of the switch from the Julian to the Gregorian calendars. Of course
if you change the Gregorian switch-over date, you'll have a different abbreviated
month somewhere else.
These modules work with the oo2c compiler with the supplied Unix replacement
module.
Here are some Date/Time modules: JulianDay, Time, SysClock, and Calendar.
---------------------------------------------------------------------------------
JulianDay translates a Gregorian date to/from a modified Julian day count
which is relative to the Gregorian date 17 Nov 1858. This module also lets
the user set the date when the local calendar switched over from the Julian
calendar to the Gregorian calendar. Additional functions return the Julian
day count and the truncated modified Julian day count.
This module is system-independent.
---------------------------------------------------------------------------------
Time provides two objects (with associated methods) to manipulate TimeStamps
and time Intervals with operations such as Add, Sub, Cmp, Init, and Diff. The
range of the Interval is from -2^31 to 2^31 days with a millisecond resolution.
TimeStamps are based on the number of days since 17 Nov 1858 with a millisecond
resolution.
This module is system-independent.
---------------------------------------------------------------------------------
SysClock.Mod is an Oberon-2 interpretation of a Modula-3 ISO standard of the
same name. It implements setting and acquisition of the system date/time.
The major changes from the ISO standard are that this module allows the time
zone and daylight savings time to be undefined for systems which do not
support these concepts. Valid dates are dependent on the installed system
but, for Unix, these are from 1 Jan 1970 to 1 Jan 2106 (with unsigned 32-bit
integers).
This module is system-dependent but should be portable to most UNIX systems.
---------------------------------------------------------------------------------
Calendar.Mod provides a western-style calendar object (derived from the
DateTime type in SysClock). The following object creation procedures are
available:
1) Init -- to initialize the Calendar date & time
2) InitFromDate -- initializes just the Calendar date; time is set to 00:00:00.
3) InitFromTimeStamp -- initializes the Calendar from a TimeStamp.
4) InitFromStr -- initializes the Calendar from a string.
The following Calendar methods are available:
1) DaysPerMonth -- maximum number of days in the current month & year.
2) Inc -- increments the Calendar by a number of days and seconds.
3) IncByMonth -- increments the Calendar by a number of months.
4) IncByYear -- increments the Calendar by a number of years.
5) DayOfWeek -- returns the day of week where Sunday=0, Monday=1, etc.
6) PaschalFullMoon -- returns the Paschal full moon date for the passed year.
7) MoonPhase -- returns the moon's phase for a given date.
7) ToTimeStamp -- converts the Calendar to a TimeStamp type.
8) FindDate -- sets the Calendar to the nth occurrence of a certain DOW.
9) WeekNumber -- the Calendar week number starting on a certain DOW.
10) DayOfYear -- the Calendar day where 1 Jan would be 1.
11) DayOfWeekStr -- returns string representation of the current DOW
12) MonthStr -- returns string representation of the current month
13) ToStr -- returns string representation according to a template pattern
Patterns for the ToStr and InitFromStr routines are built up from the
following possible template items:
`%a' The abbreviated weekday name according to the current locale.
`%A' The full weekday name according to the current locale.
`%b' The abbreviated month name according to the current locale.
`%B' The full month name according to the current locale.
`%c' The preferred date and time representation for the current
locale.
`%d' The day of the month as a decimal number (range `01' to `31').
`%D' The day of the month as above but no leading zero.
`%H' The hour as a decimal number, using a 24-hour clock (range
`00' to `23').
`%I' The hour as a decimal number, using a 12-hour clock (range
`01' to `12').
%i' The hour as a decimal number, using a 12-hour clock with
no leading zero.
`%j' The day of the year as a decimal number (range `001' to
`366').
`%m' The month as a decimal number (range `01' to `12').
`%M' The minute as a decimal number.
`%p' Either `am' or `pm', according to the given time value; or the
corresponding strings for the current locale.
`%S' The second as a decimal number.
`%U' The week number of the current year as a decimal number,
starting with the first Sunday as the first day of the first
week.
`%W' The week number of the current year as a decimal number,
starting with the first Monday as the first day of the first
week.
`%w' The day of the week as a decimal number, Sunday being `0'.
`%x' The preferred date representation for the current locale, but
without the time.
`%X' The preferred time representation for the current locale, but
with no date.
`%y' The year as a decimal number, but without a century (range
`00' to `99').
`%Y' The year as a decimal number, including the century.
`%Z' The time zone or name or abbreviation (empty if the time zone
can't be determined).
`%%' A literal `%' character.
Therefore the pattern "%A, %D %b %Y" produces "Sunday, 12 Oct 1993"
This module is system-independent.
---------------------------------------------------------------------------------
Changes this release (30 Dec 1996):
1) Calendar module now uses localized strings and templates obtained
from the Locales module.
2) Added PaschalFullMoon and MoonPhase methods to the Calendar type.
Previous release (28 Dec 1996):
1) Added a Time module with TimeStamp and Interval objects.
2) Revised the SysClock to work with undefined time zones and unknown
daylight savings mode.
3) DateTime module was replaced by the Calendar module with an object
derived from the DateTime type.
4) DateTimeStr module procedures were moved to the Calendar module.
5) JulianDay module was added.
6) All modules now work with the OO2C compiler and have been tested
on the BeBox.
Previous release (Nov 1996):
1) Fixed a couple of small bugs in the DateTimeStr.DateToStr procedure
which were spotted by Michael van Acken.
2) Totally revamped DateTimeConv.DaysToDate and DateTimeConv.DateToDays
to distinguish between Julian and Gregorian calendars and automatically
switch between them when necessary. Also removed some bugs caused
by the use of REAL numbers when LONGREAL were necessary.
3) Added a new TimeStamp to the DateTimeConv module at Michael Van Acken's
request. I really don't like the limitations inherent in the Unix
time stamp so I defined my own which is the same size as the Unix
time stamp and can represent almost any date/time.
4) Removed extraneous stuff from SysClock, again at Michael's request.
5) Added comments throughout and formatted them to display in 80 columns.
6) Changed DateTimeStr.StrToDate to return a TRUE value if the string
parsing was successful.
7) Changed the default patterns for %X, %x, and %c to be in line with
the Unix/POSIX defaults.
8) Compensate for daylight savings time (if in effect) when converting
to/from GMT times.
9) Added a procedure to DateTimeConv which returns the local time
zone abbreviation.
10)Also added the capability of setting the change-over date when the
Gregorian calendar was adopted since this date is not the same for
every country. The default is the British adoption which occurred
3 Sep 1752 (according to the Julian calendar).
Most changes above are due to Michael van Acken who has really helped
me in refining these modules to be consistent and to better meet more
of the needs of the OOC project.
<Michael Griebling grieblm@inforamp.net>