Good day bros. The following snippet:
#!/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,&nbsp;<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";
yields output:
postdate: 14th August 2017, 21:07 postdate parsed: string parsed: 2017081421:07:00
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?!?

In reply to Weird Date::Manip DateParse fail by cormanaz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.