This terrific stuff— Types::DateTime, tobyink—is going into something I’m working on. Out of the box it is parsing perfectly–

use 5.12.0; package CowTime { use Moo; use Types::DateTime -all; has timestamp => is => "ro", isa => DateTimeUTC->plus_coercions( Format['ISO8601'] ), coerce => 1; 1; }; my $original = "2019-12-07T00:07:40.587596283-05:00"; my $cowtime = CowTime->new( timestamp => $original ); say $original; say $cowtime->timestamp->time_zone; say $cowtime->timestamp->nanosecond; say $cowtime->timestamp; __END__ 2019-12-07T00:07:40.587596283-05:00 2019-12-07T05:07:40 DateTime::TimeZone::UTC=HASH(0x7f9e85ba3cd0) 587596283

It’s pulling apart the input perfectly but the output is the standard format and I’m looking for the “extended” format of the input such that the stringification will roundtrip to the form with the offset and the nanoseconds. I was set to code dive and look for the formatting hooks but I thought this was a really interesting package and wanted to put it up here. Also, I am lazy.


In reply to Types::DateTime, DateTimeUTC->plus_coercions( Format['ISO8601'] ), output format override question by Your Mother

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.