Create Calendar


Table of Contents

Introduction

This script is used to generate a calendar. By default this is in a new document that is formatted according to PageStream conventions to facilitate editing. For example, styles, master pages and tables are used. Although not presently implemented it is expected that a future version of this script will allow creating a calendar directly in an existing document.

Several calendars and various layouts are supported. While the most common calendar in use is the Gregorian calendar established by Pope Gregory XIII in 24 February 1582 there are other calendars in use and it can be of interest to generate historical calendars. Some other specialty calendars are included as well.

To use this script run CreateCalendar.py from the menu (Scripts/Play External Script...), select the calendar of choice, layout, starting and stopping dates and other parameters as set out later. Clicking the OK button will start the calendar generation. A progress bar will be displayed and can be used to cancel the operation. Up through PageStream 5.0.3.4 this functionality is broken. Once this has been fixed to effectively abort the script may require multiple clicks and is basically guaranteed to leave the document in an inconsistent state.


Table of Contents

Installation

This script can be run from anywhere as long as all script files are in the same directory. The recommended installation is to put the script files in their own directory and the documentation (this file) in the Scripts subdirectory of the PageStream help. Doing so allows PageStream to open it when the Help button in the script's GUI is clicked. The Moonwalk font can be installed in the operating system or via PageStream's font preferences. For linux an installation might look like: Note: the *.pyc files are generated automatically whenever the script is run if they do not already exist, or if the *.py file is newer.

Note: the CreateCalendar.prefs file is generated by the script when the Save button is clicked. The only effect removing it has is to return to default settings.

Note: if you want to create calendars with moon phases you will need to install the included font.

To make this script available from the Scripts menu either append the provided CreateCalendar.macro or record running the script. In either case make sure to save the loaded scripts so it will be available the next time PageStream is started

  1. Scripts/Start Recording
  2. Scripts/Play External Script...
  3. Navigate to, select and run CreateCalendar.py
  4. Cancel the script by clicking the Cancel button
  5. Scripts/Stop Recording...
  6. Name the script Create Calendar
  7. Check the Display in Menu box
  8. Set a keyboard shortcut if desired
  9. Click the OK button
  10. Window/Show Script Palette
  11. Select Save in the mini menu

Table of Contents

License

This script is an original work that is based, in part, on code in the public domain. Although copyright is asserted by the author, Tim Doty, it is freely redistributable and can be used for commercial and non-commercial work. This script is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. While every effort has been made to ensure it produces accurate calendars there is absolutely NO GUARANTEE that any given calendar produced by this script will be accurate.

Why not release under the GPL? It seems a little heavy-handed (for example, the GPL documentation recommends displaying the notice when starting the program interactively) and for scripts requiring provision of the source code for redistribution of modified code is redundant.


Table of Contents

Calendars

There are currently twelve supported calendars. The addition of calendars is simple though implementing calendrical rules may not be. To request support for a calendar contact the author. Planned calendars include additional martian ones that use timings based on Deimos and Phobos. While the Darian calendar is interesting it does not represent a likely native calendar as would have been used by Edgar Rice Burrough's martians.

Gregorian

The Gregorian calendar was established by Peope Gregory XIII in 24 February 1582 though adoption, especially in non-Catholic countries, was slow. For example, Great Britain did not adopt the Gregorian calendar until 14 September 1752. The Gregorian calendar is a refinement of the Julian calendar it succeeds, introducing a more accurate rule for determining leap years. Under the Gregorian calendar a leap year occurs every fourth year, except for years evenly divisible by one hundred, except that those even divisible by four hundred are still leap years. This produces an error of about one day every 3300 years. It should be noted that producing Gregorian calendars before its adoption is deceptive: historical dates are given in the Julian calendar which is not the same due to the difference in leap year calculation.

In the Western hemisphere the years have been traditionally designated as Anno Domini (A.D.) but with the increase for use in non-Christian centric dating the designation has been changed to Common Era (C.E.). Although not strictly speaking Gregorian, dates before the Common Era are designated Before Common Era (B.C.E.). This latter resembles the previous convention of designating such years Before Christ (B.C.). It is still common, particularly in Christian countries, to see A.D. used outside of academia and many people are unaware of the Common Era designation.

Julian

The Julian calendar comes from a reform instituted by Julius Caesar in 46 B.C.E. and took effect 45 B.C.E. This reform removed the intercalary month, fixed the month lengths and regularized the leap year in a four-year cycle. Dates before 45 B.C.E. must be adjusted to account for the various irregularities, including the year of confusion which immediately preceded adoption of the Julian calendar and was 445 days in length to bring the months into their proper seasons.

Indian Civil

The Indian civil calendar was created in 1957 out of a need to have a single unifying calendrical system that, while remaining Indian, would allow easy interoperation with the Gregorian calendar. The start point of the calendar is 22 March 79, the date of the vernal equinox in that year. The determination of leap years is 'year number plus 78, then apply the Gregorian rules'. The years of this calendar are of the "Saka Era".

Hebrew

The Hebrew calendar is a lunisolar arrangement with an intercalary month inserted at fixed intervals following the metonic cycle. This keeps the calendar roughly in sync with the lunar cycle and the solar year. The calendar is complicated by rules controlling the length of two months, Kislev and Heshvan, so as to meet religious criteria. Years are counted from the Era of Creation (Era Mundi), designated as A.M. (Anno Mundi).

Islamic Civil

The Islamic Civil calendar is a tabular lunar calendar using a 30 year leap cycle to keep it roughly in sync with the Moon while making it easy to project into the future. However most Islamic countries still use an observational lunar calendar which may vary by a day or two from this one. Each month is 30 or 29 days (alternating) with the final 29 day month extended to 30 days in leap years. Leap years are 1, 5, 7, 10, 13, 16, 18, 21, 24, 26, and 29 which is more accurate than the metonic cycle. Years are dated from Al Hijra.

Al Hijra

The Al Hijra calendar is presented as an approximation of the observed Islamic calendar using Mecca as the frame of reference. However computations can never predict with complete accuracy when the first crescent will be visible making this at best a reasonable approximation. Note: different Islamic countries use different frames of reference. In a future version this script may allow the frame of reference to be specified.

Persian

The Persian calendar is used in Iran and Afghanistan with years dating from al Hijra. However, it is a solar calendar and so has a different year number from Al Hijra. This calendar uses a complicated set of rules for determining when a leap year falls which make it the most accurate calendar in use, both in the near and long term. This is achieved by using cycles of cycles that only repeats every 2,820 years and reduces error to about one day in four million years. Although originally a strictly observational calendar in 1911 the current version, not adopted until March 31, 1925, was proposed in 1911.

French Revolution

The French Revolution calendar was created following the French revolution as part of an attempt to make everything decimal. Although defined as the first of the falling on the autumnal equinox it is here implemented as having a leap year using the Gregorian rules, excepting that the leap day is added to the preceding year. Thus years with leap days are 3, 7, 11 and so on. This coincides with the leap days observed in the short time the calendar was in effect, is one of the revisions that was proposed to make it tabular rather than observational, and matches calendars produced that were projected into the future during the time the calendar was in effect.

Available information does not make it clear if the intercalary days affected the weekday of subsequent years. The assumption here is that they do not.

Roman Lunar

Details of the actual Roman Lunar calendar are uncertain. There is adequate evidence it was originally a lunar calendar, but the details are shaky. As presented here it is a twelve month year with each month starting on the first day following a new moon and an intercalary month inserted as needed to keep in sync with the solar year. This particular interpretation is almost certainly not correct, but is adequate for a fictional representation.

The week is the 8-day market nundinal cycle which was later replaced by the 7-day planetary body cycle. The occurrence of leap years (those containing the intercalary month) is an unrealistically simple calculation. While it is most probable that the year would have started with, for example, the vernal equinox, this calculation is not yet available in the script. Instead the assumption is that the intercalary month is used if the year does not reach to the new tropical year based on comparison of year length in days with ~365.25 days per year for past years.

Although there is no weekend as such in the Roman calendar they did have a rotating market day and the market day for the year is formatted as a weekend day.

The calendar currently starts dating years from an arbitrary point in the past rather than ab urbe condita (the baseline for the actual Roman calendar, April 21, 753 B.C.E.). This may be corrected in a future version of the script.

Egyptian

This calendar is based on that used by ancient Egyptians. It uses twelve months each of thirty days with an intercalary week inserted between years to approximate the solar year. Normal weeks are ten days in length with three weeks per month. The intercalary week is not shown on the calendar and is simply assumed. The gap is visible when printing julian days however. Years in this calendar were not actually numbered so the starting point used is completely arbitrary and set to 2782 B.C.E. to coincide with the heliacal rising of Sirius in Egypt. Note: this is not currently accurate and should be considered provisional.

A later improvement, devised around 238 B.C.E though not implemented until 25 B.C.E., was made such that the intercalary week was six days in length every fourth year. That rule is not represented here.

Railog

The Railog calendar is entirely fictious and belongs to a world having a 16-hour day with months timed on a 32-day "lunar" cycle, four months to a season and four seasons to year. This gives 512 16-hour days a year, slightly shorter than a terrestrial year. Although dates are given as year-season-month-week-day_of_week the season and week designations are currently not available with any layout. Because each of the sixteen months is named uniquely they can still be identified uniquely and the days are numbered in the month. Although there is no concept of a weekend there is a market day once a week and that day is marked as a weekend.

Although there is no moon (nor planet nor astronomy as we know them) there is a celestial entity, Raimon, that rotates between Railog and Ylansi (the Sideways World). The moon phase glyphs do not accurately depict this transformation—which is rather like a coin spinning—but are used for simplicity. It is noteworthy that, unlike with our moon, direct observation of only the "lunar" entity does not reveal whether the "phase" is waning or waxing (though it is evident from other celestial positions).

Urash

The Urash calendar is entirely fictious and belongs to a world having three moons: Zazaru, a small red moon which closely orbits Urash, Nipae, a medium-sized white moon with an orbit similar to our moon, and Urnunpaea, a large blue moon which orbits more slowly. The months are timed on the 32-day synodic cycle of Nipae which happens to exactly match the 384-day solar year. All three moons are full every 80.75 years. The first day of the first year is one such occurance.

Darian

This is a tabular calendar for Mars created by Thomas Gangale in 1985. The intent was to provide a Martian calendar for human settlers. Each calendar day refers to one Martian day (24:39:35.244) with a year starting near the Martian vernal equinox. This results in a year about 668.5907 Martian days in length. A year is a leap year in odd-numbered years or those evenly divisible by 10. A leap year has an extra day added to the final month.

Months are 28 or 27 days in length, always starting on Sol Solis (the calendar's equivalent of Sunday). This results in Sol Saturni (Friday) being skipped in 27 day months.

Originally the epoch was chosen as the martian vernal equinox preceeding the first landing on Mars, which was 19 June 1976. This was day 0. Later that epoch was officially replaced with 11 March 1609. This revised epoch is the one used by this calendar.

The basic rule for determining the presence of an intercalary day is such is present in all odd numbered years and in years evenly divisible by ten. There are two additional refinements (not in years evenly divisible by one hundred, excepting those evenly divisible by five hundred) and an extended intercalation scheme intended to correct for precession. The extended scheme is not implemented here and only differs by 2 days in the first 2000 years of the Darian calendar (and won't differ by even a day until around 2525).

Reference: http://pweb.jps.net/~tgangale/mars/mst/darian.htm


Table of Contents

Layouts

At present there are five layouts available with some standard options available in the GUI. The primary limiting factor to adding new layout options is how to present them in the user interface. To request a new layout or layout options contact the author.

There are three general layout considerations: the page size, orientation and margins. The page size can be selected from the drop down and includes all page sizes known to PageStream. Orientation is likewise chosen from a drop down. The margins are as follows:

The inclusion of holidays is none, one category or all categories. If Show Holidays is not checked then no holidays will be shown. If it is is checked and one of the categories in Holiday/Event Categories is selected then only holidays from that category will be shown. If Show Holidays is checked and no category is selected then all holidays will be shown. Note: starting with the first public version following 5.0.4.4 multiselection should show all selected holidays if Show Holidays is checked.

Monthly

The monthly layout is aimed at producing documents suitable for wall hanging calendars. In particular the Skip pages and First page is blank options can be used to make the calendar grids be placed on the correct pages so that a cover and monthly illustrations can be added. A page is generated for each month included in part or whole in the designated range. Each page is put in a chapter for the year it belongs to. In this layout a master page has the page and chapter names inserted at either side of the top of the page. The page name will be the month name and the chapter name is the year. To change the placement of these elements edit the master page after the calendar has been generated. Similarly, to add the epoch designation simply insert it after the chapter name.

The core of the monthly layout is the day grid. The day number is put in the upper left corner with moon phases (if shown) right aligned. Moon phase labels (if shown) are on subsequent lines and are followed by holidays (if shown). Each textual element has its own style. Specifically:

Weekly

The weekly layout is aimed at producing a weekly view of the designated day range. Each column represents one day and every column is populated whether or not it was included in the designated day range. The day, identified by day of week, month, day of month and year, of each column is inserted into the column's header. Moon phases, moon phase labels and holidays are inserted into the main cell for the column. Each textual element has its own style. Specifically:

Weekly by Row

This weekly layout is aimed at producing a weekly view of the designated day range. Each page is labeled for the months and years having one or more days represented. Each row represents one day and every row is populated whether or not it was included in the designated day range. The day, identified by day of week, month, day of month and year, of each column is inserted into the row's header. NOTE: When using this layout it is highly recommended to change the default layout parameters, specifically the default Weekday margin is too small. Moon phases, moon phase labels and holidays are inserted into the main cell for the row. Each textual element has its own style. Specifically:

Weekly by Day

This weekly layout differs from Weekly By Row only in that the days are only designated by day of month and month name.

Appointment

The appointment layout is aimed at producing a daily planner. The master page visually divides the page into hourly rows from 8 a.m. to 6 p.m. The top of each page has the day designated by day of month, month and year with day of week identified on the next line. Holidays (if shown) are presented in the upper right corner of the page. A vertical rule visually separates the day designation from the holiday text. Each textual element has its own style. Specifically:

Daily

The daily layout is aimed at producing a day calendar such as are often seen in offices. It uses a box with a horizontal rule dividing the year and month label from the day number.

Mini Monthly

The mini monthly layout is very restricted and ignores many of the options. It produces a monospaced text calendar grid, optionally with lunar phase symbols but nothing else. It is aimed at providing the previous and next "mini" calendars found in some monthly layouts.

Table of Contents

Other Options

Layout Method

The general method of layout, that is: if the calendar will be created in a document, in a new chapter of the current document, or on the currently active page of the current document.
New Document
A new document is created using the specified page size and margins for defining master pages.
New Chapter
A new chapter in the current document is created using the specified page size and margins for defining the master page to be used in this chapter.
Current Page
The calendar will be created on the active page of the current document (and following pages as necessary). The page size selection made in the requester is ignored and no master pages are created. Instead the script uses the dimensions of the current page. The margins (top, bottom, left and right) are still used as offsets from the page boundaries to determine the size of the calendar.

Day Format

The script exposes an enhanced version of PageStream's built in date formatting functionality which can be used to control how the day is displayed in the calendar. The default is to simply use the day numeral. Several presets are included in the drop down menu. If none of those suffice then the custom setting can be used.

In addition to the standard PageStream formatting codes the script has extensions for roman numerals and roman day designations. These are as follows:

RRRR
The year represented in capitalized roman numerals
rrrr
The year represented in lowercased roman numerals
RR
The month number represented in capitalized roman numerals
rr
The month number represented in lowercased roman numerals
R
The day of month number represented in capitalized roman numerals
r
The day of month number represented in lowercased roman numerals
Rrrrr
The day's full roman day designation with classic capitalized roman numerals
rrrrr
The day's full roman day designation with classic lowercased roman numerals
Rrrr
The day's abbreviated roman day designation with classic capitalized roman numerals, month is abbreviated to four letters
rrrr
The day's abbreviated roman day designation with classic lowercased roman numerals, month is abbreviated to four letters
Rrr
The day's abbreviated roman day designation with classic capitalized roman numerals, month is abbreviated to three letters
rrr
The day's abbreviated roman day designation with classic lowercased roman numerals, month is abbreviated to three letters
Classic roman numerals are purely additive. In otherwords 9 is VIIII, not IX. The subtractive form is a modern invention.

To not display the day at all, whether by name or number, select Custom and leave the format string empty.

Julian Day Options

The Julian Day number for the calendar day can be displayed with a variety of offsets.
None
No Julian Day number is displayed
Julian
Simply displays the Julian Day number
Modified
Modified count starting at midnight morning of November 17, 1858 (JDN - 2400000.5)
Truncated
Truncated count starting at midnight UT morning of May 24, 1968 (JDN - 2440000.5)
Calendar
Counts days from the beginning of the calendar's count
Annual
Displays the day of year instead of a Julian Day
Dublin
Count starts at noon UTC on 0 January 1900 (JDN - 2415020)
Lilian
Count starts October 15, 1582 (JDN - 2299159.5)
ANSI
Count starts January 1, 1601 (JDN - 2305446.5)

Lunar Options

There are several options for how the lunar phases should be displayed, if at all. If pictures of the lunar phase are to be used then an appropriate font must be installed.

Pictures and textual labels for the phases can be independantly set to None, Quarters and All. When set to Quarters only the New Moon, First Quarter, Full Moon and Last Quarter moon phases are displayed.

The Alternate lunar option is used to select the alternate set of lunar phase pictures. The default set have the lunar phase picture circumscribed by a circle, the alternate set does not. In the alternate set a New Moon is displayed as an empty circle.

Holiday and Event Options

The occurance and display of holidays and events is highly configurable. A number of holiday definitions are provided with the script and others can be added by editing the holiday definition file.

Some holidays or events, such as Easter, require complex formula to determine when they occur. These formula are encoded in the script (specifically in Calendar.py).

The holiday file, holiday.txt consists of a series of comments and holiday definitions using the following format:

Saved Preferences

The current settings can be stored in a preferences file, CreateCalendar.prefs, by clicking the Save button. This file can also be edited by hand. It consists of two types of lines: comments and values.

Any line that starts with a hash, '#', is a comment. All other lines represent stored values in the form:
     variable: value

Note: the entire file is rewritten whenever the Save button is clicked so any changes made by hand, such as comments, will be lost.


Table of Contents

Notes

Moon Phases Font

The freely redistributable Moonwalk font by Deron Kazmaier is included with this script and supports both the previous 28-glyph moon phases as well as an extended 200-glyph moon phase cycle. Future versions will take advantage of the extended glyph set so it is recommended to install this font.

If for some reason a different moon phase font is desired one source of a moon phases font is mockfont. Quoted from the site "All the fonts available here are Copyright © 1992-1998 by Curtis Clark. They are free for personal use. For other uses, please see the licensing agreement."

The same font is also available from www.dafont.com.

Script Known Issues

Windows Known Issues

Linux Known Issues

OS X Known Issues

To Do List

The following, in no particular order, are items to be implemented. Known issues mentioned elsewhere are implied.
Another one you may think of is our Koninginnedag (Queens day) which 
happens to be on April 30.

   fixed 0430 Nederlands Koninginnedag

   But this is true except when this holiday takes place on a Sunday, 
then it will be scheduled to the day before namely: Saturday April 29!
   We are still a Christian country, yet :-) .

   Can you catch this in a formula?

Your answer was:

   Darn! Maybe, but it'd have to be a new one. The equivalent in the US 
is "observed". For example, Christmas (Dec 25) is a Federal holiday.
   Except if it falls on Saturday or Sunday, in which case it is moved 
to the nearest weekday.

   Mind you Christmas itself is always Dec 25, but it might be observed 
as a Federal holiday on Dec 26 or Dec 24.

    There aren't any rules to quite do what you want. I may make another 
"rule" to allow more flexible exceptions (regular formula [fixed or 
rule] EXCEPT 

Table of Contents

Contact Information

Author:  Tim Doty
Email:   drakki@rollanet.org
Support: PageStreamSupport@yahoogroups.com
    
Due to spam there is the very real possibility that directly emailing the author will not be effective. It is best to use the PageStream support list. In the event the issue relates to PageStream behavior it will be necessary to use the support list anyway.