I've been away from this list for quite some time but I'm back doing some
datetime stuff. Nothing fancy but much easier than home-grown.
While testing some code I ran into the situation that I can deal with but
would prefer not having to.
Short story usng the truncate method on a datetime object that was created
with a format destroys/removes the format -- forever. Then while writng
this message I found that when I try to create a copy ( well probably not
as the results show otherwise ) that it is an alias/reference?
<code>
use DateTime;
use DateTime::Format::Strptime;
my $formatter =
DateTime::Format::Strptime->new( pattern => "%Y%m%d%H%M%S" );
my $dt =
DateTime->now( time_zone => 'America/Los_Angeles' ,
formatter => $formatter );
my $dt2 = $dt;
print "$dt\n$dt2\n";
$dt->truncate( to => 'minute' );
print "$dt\n$dt2\n";
</code>
Gives these results.
20050804120543
20050804120543
2005-08-04T12:05:00
2005-08-04T12:05:00
Is this a known thingy? ( Did I discover something new? :-) Is there a
work around? I didn't find anything in the documentation about this?
And nothing so far in the archives. I'd like to use the same datetime
object for two different purposes.
Rod
--
"Open Source Software - You usually get more than you pay for..."
"Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL"