On Sunday, August 10, 2003, at 08:08 PM, Dave Rolsky wrote:
On Sun, 10 Aug 2003, John Siracusa wrote:
We have enough constructors as it is.

Well that's not my fault :) If, for whatever reason, you're going to limit DateTime to N constructors, they should be the N most likely to be used. Do you really think from_day_of_year() is going to be called more often than now(time_zone => 'local')?

If you only have a year and day of year, then having a from_day_of_year
constructor saves a _lot_ of calculation that end users have to do. OTOH,
having to do 'DateTime->now(time_zone => "local")' isn't very onerous at
all.

...unless that's the only way you will *ever* call now()! :) Seriously, who is calling now() *without* time_zone => 'local' arguments? I haven't done so yet, and would like to hear some examples of this usage.


Here's example of what I expect to be common usage. Let's say someone want the default date range in the text fields on a web form to be "the past 30 hours." Joe Perl Programmer is going to glance at the DT docs and then write:

        $start = DateTime->now->subtract(hours => 30)->strftime(...);
        $end   = DateTime->now->strftime(...);

Joe Perl Programmer is going to be very surprised, IMO, and the fix is not to add warnings to the docs... ;)

-John



Reply via email to