4.11.1 CalendarsBy default, the time.fromCalendar function makes a transition from the old Julian calendar to the new Gregorian calendar at midnight on 14th September 1752 (Gregorian calendar), when Britain and the British Empire switched calendars. Thus, dates between 2nd September and 14th September 1752 are not valid input dates, since they days never occurred in the British calendar. This behaviour may be changed using the set calendar command, which offers a choice of nine different calendars listed in Table 4.2. Most of the these calendars differ only in the date on which the transition is made between the old (Julian) calendar and the new (Gregorian) calendar. The exceptions are the Hebrew and Islamic calendars, which have entirely different systems of months.
Optionally, the set calendar command can be used to set different calendars to use when converting calendar dates into date objects, and when converting in the opposite direction. This is useful when converting data from one calendar to another. The syntax used to do this is as follows: set calendar in Julian # only applies to time.fromCalendar() set calendar out Gregorian # does not apply to time.fromCalendar() set calendar in Julian out Gregorian # change both show calendar # show calendars currently being used Example: Calculating the date of Leo Tolstoy’s birth The Russian novelist Leo Tolstoy was born on 28th August and died on 7th November in the Russian calendar. What dates do these correspond to in the Western calendar? pyxplot> set calendar in russian out british pyxplot> birth = time.fromCalendar(1828, 8,28,12,0,0) pyxplot> death = time.fromCalendar(1910,11, 7,12,0,0) pyxplot> print birth Tue 1828 Sep 9 12:00:00 UTC pyxplot> print death Sun 1910 Nov 20 12:00:00 UTC
|