Stringer has asked for the wisdom of the Perl Monks concerning the following question:
The 'locale' parameter (undef) to DateTime::new was an 'undef', which +is not one of the allowed types: scalar object at /usr/lib/perl5/site_perl/5.8.5/Params/ValidatePP.pm line 634 Params::Validate::__ANON__('The \'locale\' parameter (undef) to Da +teTime::new was an \'un...') called at /usr/lib/perl5/site_perl/5.8.5 +/Params/ValidatePP.pm line 485 Params::Validate::_validate_one_param('undef', 'HASH(0x1039fb0)', +'HASH(0xe04910)', 'The \'locale\' parameter (undef)') called at /usr/ +lib/perl5/site_perl/5.8.5/Params/ValidatePP.pm line 345 Params::Validate::validate('ARRAY(0xa87370)', 'HASH(0xe284a0)') ca +lled at /usr/lib64/perl5/site_perl/5.8.5/x86_64-linux-thread-multi/Da +teTime.pm line 171 DateTime::new('undef', 'year', 2015, 'month', 08, 'day', 24, 'hour +', 17, ...) called at MonitorClass.pm line 80 MonitorClass::MakeDateTime('MonitorClass=HASH(0xf03430)', 2015, 08 +, 24, 17, 36, 47, 144) called at MonitorClass.pm line 196
This is driving me nuts, as the parameters sent to DateTime->new() are correct, as can be seen in the final line of my error. I'm not even able to reproduce the issue consistently. For the vast majority of cases my code works great but every morning when I get into work I see that it's thrown the above a few times.
I'm going to try explicitly setting the locale parameter each time I call DateTime->new(); but I'd rather understand what I'm doing wrong here.
Here's my method that's invoking DateTime->new(); it's ridiculously simple:sub MakeDateTime { my $self = shift; my ($Year, $Month, $Day, $Hour, $Minute, $Second, $MilliSecond) = @_ +; my $DateTime = DateTime->new( year => $Year, month => $Month, day => $Day, hour => $Hour, minute => $Minute, second => $Second, nanosecond => ($MilliSecond * 1000000), time_zone => 'America/New_York', locale => 'en_US', ); return $DateTime; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Strange Params::Validate Error
by stevieb (Canon) on Aug 26, 2015 at 14:03 UTC | |
Re: Strange Params::Validate Error
by toolic (Bishop) on Aug 26, 2015 at 13:54 UTC | |
by Monk::Thomas (Friar) on Aug 26, 2015 at 14:38 UTC | |
Re: Strange Params::Validate Error
by anonymized user 468275 (Curate) on Aug 27, 2015 at 15:42 UTC |