Re: DateTime and Test::MockTime

[email protected] (Zefram)
Newsgroups perl.datetime
Message-ID <[email protected]>
Mark Pitchless wrote:
>For some reason using DateTime->now doesn't get effected by using the
>Test::MockTime module to change the time.

It does if you load Test::MockTime before you load DateTime.

$ perl -MDateTime -MTest::MockTime=:all -lwe 'print time;print DateTime->now;set_relative_time(6000);print time;print DateTime->now' 
1219919095
2008-08-28T10:24:55
1219925095
2008-08-28T10:24:55
$ perl -MTest::MockTime=:all -MDateTime -lwe 'print time;print DateTime->now;set_relative_time(6000);print time;print DateTime->now'
1219919098
2008-08-28T10:24:58
1219925098
2008-08-28T12:04:58
$

-zefram
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.