time, calendar, datetime, etc
newsgroups at jhrothjr.com
Mon Aug 4 01:16:28 CEST 2003
"Tim Peters" <tim.one at comcast.net> wrote in message
news:mailman.1059930907.27623.python-list at python.org...
> [Dan Bishop]
> > There were no leap years between 10 BC and AD 4, because after Julius
> > Caesar's death, the priests in charge of the calendar mistakenly added
> > leap days every 3 years instead of 4, and this had to be corrected.
> > I wouldn't expect the datetime module to deal with that, though ;-)
> Thank you -- some people did <wink>.
I don't think I noticed that: the entire point behind the proleptic
calender is that you're projecting the current practice back to
times where they weren't doing it that way.
That's clearly an opportunity for someone to add an extension -
except that there are other problems in that era, and the lack
of leap years is the least of them.
> > ...
> > >>> datetime.date(1970, 8, 22).weekday()
> > 5
> > >>> datetime.date(6970, 8, 22).weekday()
> > 5
> > The output above is my least favorite feature of the datetime module.
> > It took me a while to figure out that those dates are Saturdays.
> That's very peculiar! Because they're not both Saturdays:
> >>> datetime.date(1970, 8, 22).weekday()
> >>> datetime.date(6970, 8, 22).weekday()
> Or if you want names instead:
> >>> datetime.date(1970, 8, 22).ctime()[:3]
> >>> datetime.date(6970, 8, 22).ctime()[:3]
> Did you actually run the example you pasted, or just assume that the
> line would display 5 too, or didn't paste the actual example you ran and
> made a typo?
> The earlier claim:
> > The Gregorian leap year cycle is 400 years and this is coincidentally
> > also a whole number of weeks.
> was correct, but the 5000 years between 1970 and 6970 isn't a multiple of
> 400, so the example as given wasn't relevant to that claim.
> > Perhaps we could add a weekday class to 2.3.1?
> > DAY_NAMES = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday',
> > 'Saturday', 'Sunday']
> > class weekday(int):
> > def __repr__(self):
> > return DAY_NAMES[self]
> > for i, name in enumerate(DAY_NAMES):
> > globals()[name] = weekday(i)
> I doubt anything like this will get added, in part because we have the
> unfortunate fact that .weekday() and .isoweekday() map day names into
> integers differently. As shown above, you can easily get English day
> (well, abbreviations) from the .ctime() result. A .strftime() format
> too, except .strftime() has irritating year-range limitations inherited
> I have a little dateutil.py module I use for my own stuff, containing
> MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY = range(7)
> (JANUARY, FEBRUARY, MARCH, APRIL, MAY, JUNE,
> JULY, AUGUST, SEPTEMBER, OCTOBER, NOVEMBER, DECEMBER) = range(1, 13)
> at the start. That's easy, and caters to that (1) I'm unlikely ever to
> .isoweekday(); and, (2) after decades of practice, I'm comfortable with
> English names for these things. It's much easier to do something similar
> for yourself than to try to define a gimmick that covers the union of all
> peoples' crazy ideas <wink>.
More information about the Python-list