> So if we're now on 1-indexing, we'll see lots of @months = (undef, 'Jan',
> 'Feb') or qw(dummy Jan Feb)... oh well.
Far better, use the new builtin object methods:
$d = date;
print "today is ", $d->date('%A'); # Friday
> Apparently, neither is hour. And why not, pray? I'd like to see the
> justification for this decision.
Here is the justification. As most people write dates, they write
something like this:
1/20/1976 2:34:02
4/5/981 11:05:09
Very few people I've met write dates like this habitually in the real
world:
01/20/1976 02:34:02
04/05/0981 11:05:09
And I've never seen anyone write this:
1/20/1976 2:34:2
4/5/981 11:5:9
Notice that the hours/mins are always padded but the rest isn't.
If you're writing a program that uses the date as an actual date (and
not as a file suffix, for example), you'll probably want to present what
people are used to seeing, in this case the first one. And if you want a
file suffix, use what I suggested in the RFC:
$backup_suffix = date time, '%Y%m%d%H%M%S';
Which would return something like "20001104120309".
> While you're at the padding job, make $hour, $mon, and $mday zero-padded
> to two decimal places as well, for consistency.
I've gone back and forth about this. I ultimately think that the above
approach will end up with date() being more usable in more situations,
even though it seems a little inconsistent. I think it returns what
people want, it's just that people are inconsistent.
Remember, localtime is already a very consistent interface from a lot of
aspects, but it is horribly unusable because it doesn't return stuff in
the form you want it.
-Nate