Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re^5: Month '-1' out of range 0..11

by kennethk (Abbot)
on Mar 18, 2014 at 16:26 UTC ( #1078803=note: print w/replies, xml ) Need Help??

in reply to Re^4: Month '-1' out of range 0..11
in thread Month '-1' out of range 0..11

#!/usr/bin/perl -w use strict; use Time::Local; my $finaltime = UTCtoLocal(); print "$finaltime \n"; sub UTCtoLocal { my @ActTime = map {/"(.*?)"/} grep {/MessageDateTime/} (<DATA>); my $iso_time = join("", @ActTime); my $expected_epoch = 1 * 60 * 60 + 1 * 60 + 1; my ($date, $time) = split /T/ => $iso_time; my ($year, $mon, $mday) = split /-/ => $date; $year -= 1900; $mon -= 1; my ($hour, $min, $sec) = split /:/ => $time; my $nsec = chop($sec); my $mtime = timegm($sec, $min, $hour, $mday, $mon, $year); return ($mtime); } __DATA__ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE ScheduleMessage SYSTEM "../schedulev2r3/dtd/schedule-xml.dtd +"> <ScheduleMessage DtdVersion="2" DtdRelease="3"> <MessageIdentification v="8787897987897897" /> <MessageVersion v="097" /> <MessageType v="A01" /> <ProcessType v="A02" /> <ScheduleClassificationType v="A01" /> <SenderIdentification v="9090900" codingScheme="A01" /> <SenderRole v="A01" /> <ReceiverIdentification v="453543453453" codingScheme="A01" /> <ReceiverRole v="A04" /> <MessageDateTime v="2014-03-18T15:41:14Z" /> <ScheduleTimeInterval v="2014-03-13T23:00Z/2014-03-14T23:00Z" /> <ScheduleTimeSeries> <SendersTimeSeriesIdentification v="65765675765" /> <SendersTimeSeriesVersion v="001" /> <BusinessType v="A06" /> <Product v="8716867000016" /> <ObjectAggregation v="A01" /> <InArea v="10YFRkjkjkl" codingScheme="A01" /> <OutArea v="10YCHiuiuoiu" codingScheme="A01" /> <InParty v="jkkljkljlkj" codingScheme="A01" /> <OutParty v="uiouiouoiuo" codingScheme="A01" /> <MeasurementUnit v="MAW" /> <Period> <TimeInterval v="2014-03-13T23:00Z/2014-03-14T23:00Z" /> <Resolution v="PT15M" />
outputs 1395157274 as I would expect. You have scrubbed the issue out of your code. Unless you post material that displays the issue you are referencing, I cannot help.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1078803]
[hippo]: Yary: There are a few useful pointers in I need perl coding standards
[hippo]: ... and a boatload of good stuff in On Coding Standards and Code Reviews
[Yary]: Looking at system pm's, looks like it's "package" on the first line, then POD, then "use;use strict; use warnings; use modules..."
[Yary]: ah thanks for those links
[hippo]: Just bear in mind that all such ideas are subjective.
[choroba]: There might be a different standard at the shop you write the code for.

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2018-01-23 16:58 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (250 votes). Check out past polls.