Skip Menu |

This queue is for tickets about the Test-MockTime CPAN distribution.

Report information
The Basics
Id: 43216
Status: resolved
Priority: 0/
Queue: Test-MockTime

People
Owner: Nobody in particular
Requestors: user42 [...] zip.com.au
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: suggest mock Date::Calc too
Date: Thu, 12 Feb 2009 06:24:42 +1100
To: bug-Test-MockTime [...] rt.cpan.org
From: Kevin Ryde <user42 [...] zip.com.au>
I'd be good if Test::MockTime could jig up overrides for the Date::Calc current time funcs too. The basic ones I spot are (among which I've been using Today() ...), System_Clock Today Now Today_and_Now This_Year And a couple default to the current time and so would want the fake current time substituted, Gmtime Localtime (They're all xsubs, so don't go through the CORE:: overrides already.) The various other Date::Calc funcs might be able to do most of the actual work, starting from a time_t for the faked current time. It'd be tempting to have Test::MockTime mangle Date::Calc automatically if it's loaded, or mangle when later loaded (if that's feasible). Otherwise an option to load and mangle could be ok if that's easier or more reliable (esp if other modules import Date::Calc funcs).
On Wed Feb 11 17:14:36 2009, user42@zip.com.au wrote: Show quoted text
> I'd be good if Test::MockTime could jig up overrides for the Date::Calc > current time funcs too. The basic ones I spot are (among which I've > been using Today() ...), > > System_Clock > Today > Now > Today_and_Now > This_Year > > And a couple default to the current time and so would want the fake > current time substituted, > > Gmtime > Localtime > > (They're all xsubs, so don't go through the CORE:: overrides already.) > The various other Date::Calc funcs might be able to do most of the > actual work, starting from a time_t for the faked current time. > > It'd be tempting to have Test::MockTime mangle Date::Calc automatically > if it's loaded, or mangle when later loaded (if that's feasible). > Otherwise an option to load and mangle could be ok if that's easier or > more reliable (esp if other modules import Date::Calc funcs).
Always happy to apply supplied patches, but this sounds like it'd be much more work mocking Date::Calc rather than simply patching Date::Calc to use the perl time function?
used Kevin Ryde's lib/Test/MockTime/DateCalc.pm and t/DateCalc.t. May need/want to split these files into a separate module.