Bug in nanosecond handling in DT::Incomplete?
[email protected] (David Dyer-Bennet) Thu, 29 Apr 2021 17:25:12 -0500
| Newsgroups | perl.datetime |
|---|---|
| Message-ID | <[email protected]> |
--------------64E3967E538B2D6CB22FD40B
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
I can't find this behavior in the docs and I can't see how it might be
useful, so maybe this is just a bug?
This code:
#!/usr/bin/env perl
# Test Datetime::Incomplete and straight Datetime behavior
use DateTime;
use DateTime::Incomplete;
use strictures 2;
my %parms = (
year => 2021,
month => 4,
day => 11,
hour => 16,
minute => 52,
second => 33,
nanosecond => 600
);
my $dt = DateTime->new (%parms);
print $dt->strftime ("%FT%T.%N %Z"), "\n";
$dt = DateTime::Incomplete->new (%parms);
print $dt->strftime ("%FT%T.%N %Z"), "\n";
When run (on FreeBSD) produces this output:
$ ./t009.pl
2021-04-11T16:52:33.000000600 floating
2021-04-11T16:52:33.09d xxxxx
The "%N" format specifier produces "09d" in the second case (from a DT::Incomplete), which rather looks like what a printf format specifier should be rather than what the actual output should look like?
--
David Dyer-Bennet,[email protected];http://dd-b.net/
Words Over Windowshttp://WordsOverWindows.dd-b.net/
Snapshots:http://dd-b.net/dd-b/SnapshotAlbum/data/
Photos:http://dd-b.net/photography/gallery/
--------------64E3967E538B2D6CB22FD40B
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 7bit
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<p>I can't find this behavior in the docs and I can't see how it
might be useful, so maybe this is just a bug?</p>
<p>This code:</p>
<pre>#!/usr/bin/env perl
# Test Datetime::Incomplete and straight Datetime behavior
use DateTime;
use DateTime::Incomplete;
use strictures 2;
my %parms = (
year => 2021,
month => 4,
day => 11,
hour => 16,
minute => 52,
second => 33,
nanosecond => 600
);
my $dt = DateTime->new (%parms);
print $dt->strftime ("%FT%T.%N %Z"), "\n";
$dt = DateTime::Incomplete->new (%parms);
print $dt->strftime ("%FT%T.%N %Z"), "\n";
</pre>
<p>When run (on FreeBSD) produces this output:</p>
<pre>$ ./t009.pl
2021-04-11T16:52:33.000000600 floating
2021-04-11T16:52:33.09d xxxxx
The "%N" format specifier produces "09d" in the second case (from a DT::Incomplete), which rather looks like what a printf format specifier should be rather than what the actual output should look like?
</pre>
<pre class="moz-signature" cols="72">--
David Dyer-Bennet, <a class="moz-txt-link-abbreviated" href="mailto:[email protected]" moz-do-not-send="true">[email protected]</a>; <a class="moz-txt-link-freetext" href="http://dd-b.net/" moz-do-not-send="true">http://dd-b.net/</a>
Words Over Windows <a class="moz-txt-link-freetext" href="http://WordsOverWindows.dd-b.net/" moz-do-not-send="true">http://WordsOverWindows.dd-b.net/</a>
Snapshots: <a class="moz-txt-link-freetext" href="http://dd-b.net/dd-b/SnapshotAlbum/data/" moz-do-not-send="true">http://dd-b.net/dd-b/SnapshotAlbum/data/</a>
Photos: <a class="moz-txt-link-freetext" href="http://dd-b.net/photography/gallery/" moz-do-not-send="true">http://dd-b.net/photography/gallery/</a></pre>
</body>
</html>
--------------64E3967E538B2D6CB22FD40B--