cormanaz has asked for the wisdom of the Perl Monks concerning the following question:
yields output:#!/usr/bin/perl -w use strict; use Date::Manip; use HTML::TreeBuilder; my $htm = ' <html><div class="posthead"> <span class="postdate new"><span class="date">14th August 2017, <span class= "time">21:07</span></span></span> <span class= "nodecontrols"><a name="post27949278" href= "threads/2360460-product-reviews.htm" class="postcounter">#1937</a></span> </div></html>'; my $tree = HTML::TreeBuilder->new_from_content($htm); my $postdate = $tree->look_down('class','date')->as_text(); print "postdate: $postdate\n"; print "postdate parsed: ",ParseDate($postdate),"\n"; my $timestamp = '14th August 2017, 21:07'; print "string parsed: ",ParseDate($timestamp),"\n";
So it fails to parse a date when it's passed to ParseDate as the contents of a variable gotten with HTML::Element, but if I take the exact same text, assign it to a variable as a string literal, and pass it to ParseDate, it parses fine. I've debugged into Date::Manip and it seems to be getting the same string in both cases. Anyone know what's going on here?!?postdate: 14th August 2017, 21:07 postdate parsed: string parsed: 2017081421:07:00
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Weird Date::Manip DateParse fail
by Corion (Patriarch) on Aug 17, 2017 at 18:37 UTC | |
by dbander (Scribe) on Aug 17, 2017 at 19:21 UTC | |
by cormanaz (Deacon) on Aug 17, 2017 at 19:31 UTC | |
by ExReg (Priest) on Aug 18, 2017 at 15:33 UTC | |
by snax (Hermit) on Sep 29, 2017 at 02:09 UTC |