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

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

by kennethk (Monsignor)
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.


Comment on Re^5: Month '-1' out of range 0..11
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1078803]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2014-10-25 23:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (149 votes), past polls