Re: Data::Juxtapose 0.01 [Re: patch: DateTime::TimeZone PP redundant structures]

2005-07-19 Thread Matt Sisk
The basic format seems good. I'm not sure about using weak_ref, though
-- what if an object or structure falls out of scope, yet there's still
a key in the data registry? If another ref comes along whose fingerprint
matches that key, does it end up getting replaced with undef ? (I'm kind
of sleepy at the moment, so I could be misreading the code).

Also, as originally implemented in the context of DateTime::TimeZone, I
was using class structures and class methods. You've moved it into
object mode, which is fine, but I'm curious as to how you utilize the
shared object. I'm assuming it's a single object in the DT::TZ base class?

Cheers,
Matt



Re: Data::Juxtapose 0.01 [Re: patch: DateTime::TimeZone PP redundant structures]

2005-07-19 Thread Daisuke Maki

 The basic format seems good. I'm not sure about using weak_ref, though
 -- what if an object or structure falls out of scope, yet there's still
 a key in the data registry? If another ref comes along whose fingerprint
 matches that key, does it end up getting replaced with undef ? (I'm kind
 of sleepy at the moment, so I could be misreading the code).

I had a reason why I did that, but I can't seem to come up with a good
reason now. Hmm. I suppose it won't hurt to *not* have it, I guess I can
just remove it.

 Also, as originally implemented in the context of DateTime::TimeZone, I
 was using class structures and class methods. You've moved it into
 object mode, which is fine, but I'm curious as to how you utilize the
 shared object. I'm assuming it's a single object in the DT::TZ base class?

Yeah, that's what I was planning to do. just hold a class variable that
points to a D::J object.

--d


RE: Error Message using Time::Local

2005-07-19 Thread Hill, Ronald


Hi Behzad,

(snipped)


 
CASE 1
--
 use Time::Local 'timelocal_nocheck';


use Time::Local qw(timelocal_nocheck timelocal);


Should fix that :-)
 

 
CASE 2
--
 Use Time::Local;
 
 Use of uninitialized value in integer multiplication (*) at
C:/Perl/lib/Time/Local.pm line 76 (#1)
 
Day '31' out of range 1..30 at c:\myCode.pl 98
At C:/Perl/lib/Time/Local.pm line 116
Time::Local::timegm called at C:/Perl/lib/Time/Local/pm line
153
Time::Local::timelocal(0, 0, 0, 31, 08, 2004) called at
C:\myCode.pl line 98

From the Time::Local Docs 

 It is worth drawing particular attention to the expected ranges for the
values provided. The value for the day of the month is the actual day
(ie 1..31), while the month is the number of months since January
(0..11). This is consistent with the values returned from localtime()
and gmtime().

So, If you wanted a date of Aug 31, 2004 the call to timelocal
Should be:
my $time = timelocal(0, 0, 0, 31, 7, 2004);

And to confirm
use strict;
use DateTime;
use warnings;
use Time::Local qw(timelocal_nocheck timelocal);

my $time = timelocal(0, 0, 0, 31, 7, 2004);

my $dt = DateTime-from_epoch( epoch = $time );

print $dt-mdy;

prints:
D:\scriptsme.pl
08-31-2004

I hope this helps

Ron Hill



Date time Issue

2005-07-19 Thread Anthony, Joseph
Hi,

 

I've an issue storing a datetime value in oracle db from a perl module.

 

Below is the issue,

The string date has a value as 'Jul 18, 2005 7:45:17 PM' and when I directly
store it to an oracle database field datetime, it's storing as

07/18/2005 07:45:17 AM. Not sure why it's converted to AM instead PM.

 

 

Could you please let me know if I have to do anything (any conversion)
before I store it there.

 

 

Thanks,

 

 

Joseph



Re: Date time Issue

2005-07-19 Thread Rick Measham

Anthony, Joseph wrote:

The string date has a value as 'Jul 18, 2005 7:45:17 PM' and when I directly
store it to an oracle database field datetime, it's storing as

07/18/2005 07:45:17 AM. Not sure why it's converted to AM instead PM.


I don't recognise the format, and anything other than ISO datetimes can 
be confusing so I'd use the swiss-army-parser to convert from your 
existing format to an ISO datetime: DateTime.pm. Over the past couple of 
years we've developed quite a tool suite, and in this case I'd use 
DateTime::Format::Strptime to parse the existing code.



use DateTime::Format::Strptime;

my $parser = DateTime::Format::Strptime-new(
pattern = '%b %d, %Y %I:%M:%S %p'
);

$converted_to_iso = $parser-parse_datetime( $original )-datetime;


# or Procedural:

use DateTime::Format::Strptime qw/strptime strftime/;

$converted_to_iso = strftime(
'%Y-%m-%d %H:%M:%S',
strptime(
'%b %d, %Y %I:%M:%S %p',
$original
)
);