Forgive me for I have displayed my ignorance.
Cheers!
Rick
On Fri, 7 Feb 2003, Rick Measham wrote:
Would you consider letting the new() method optionally take a
DateTime object?
There's a "DateTime->from_object" method already.
Extending further we could move other stuff too:
my $here = DateTime->new(datetime=>$rth, hour => 19);
which would set $here to a clone of $rth, but with the hour set to 19.
You ask me for a use for this? How about something that expires
today at midnight? (23:59:60 or Tomorrow at 00:00:00 depending on
your perspective, see Note 1)
Let's imagine our application has already set
$NOW = DateTime->now;
so all we need to do to get midnight tonight is:
$midnight = DateTime->new(datetime=>$NOW, hour=>23, minute=>59, second=>60);
rather than
$midnight = DateTime->new(year=>$NOW->year, month=>$NOW->month,
day=>$NOW->day, hour=>23, minute=>59, second=>60);
For all this stuff you might as well just do:
my $new = $dt->clone;
$new->set( hour => 23 );
The only problem is that setting the time zone changes the local time, and
you wanted a way to change the time zone without changing the local time.
That just requires another method that is unambiguously different from
"set_time_zone()".
-dave
/*=======================
House Absolute Consulting
www.houseabsolute.com
=======================*/
--
--------------------------------------------------------
There are 10 kinds of people:
those that understand binary, and those that don't.
--------------------------------------------------------
The day Microsoft makes something that doesn't suck
is the day they start selling vacuum cleaners
--------------------------------------------------------