On Sat, 11 Jan 2003, Rich Bowen wrote: > On Fri, 10 Jan 2003, Dave Rolsky wrote: > > > Can we simply declare 0-based as the standard for day of week and day of > > year, and 1-based for day of month, month of year, and week of year. > > FWIW, that's what Date::ICal already had implemented, I believe. > > The reasoning here, although I don't know that we ever explicitly > discussed it is thus. Things should be 1-based if they are 1-based in > real usage. March 1 is the 1st day of the month, not the 0th. Calling > March 1 day 0 will inevitably confuse everyone who did not write the > module. Things should be 0 based if they are called by name in general > usage. Thus, day of week should probably be 0-based. Month is a little > less pleasant, but can be thought about thus. You usally use the month > number as a list index. Thus, Jan should be 0 because @months is (Jan, > Feb, etc)
This is a really good way to look at it. I think this can go into the module docs as is, along with an explicit list of which number-returning methods return 0-based, and which 1-based. > > month/monname - abbreviated name (Jan Feb ...) > > fullmonth - full name > > mon - 1-12 > > _mon - 0-11 > > That might be a nice way to handle it if this is made abundantly clear > every time one of these things is referenced in the docs. Too many date > modules assume you know that things are 0 based. Or 1 based, as the case > might be. This is actually how Time::Piece documents all its methods. For DateTime.pm, I'll stick this sort of thing in the synopsis, so people see it right away. That way it's quick to get at when you forget ;) -dave /*======================= House Absolute Consulting www.houseabsolute.com =======================*/
