Bug#827241: add note that add_years() need not be an integer

積丹尼 Dan Jacobson jidanni at jidanni.org
Tue Jun 14 00:27:11 UTC 2016


Package: perl-doc
Version: 5.22.2-1
Severity: wishlist
File: /usr/share/man/man3/Time::Piece.3perl.gz

Add a note that add_years() need not be an integer.
Very convenient for e.g., "half a year ago"
add_years(-1/2);

But also add a note that it only has one month granularity,
08:18 ~$ perl -wle 'use Time::Piece; $t=localtime; $r=rand(); print $r, " ", $t->add_years($r);'
0.954227251540036 Sun May 14 08:18:46 2017
08:18 ~$ perl -wle 'use Time::Piece; $t=localtime; $r=rand(); print $r, " ", $t->add_years($r);'
0.89047924972056 Fri Apr 14 08:18:50 2017
08:18 ~$ perl -wle 'use Time::Piece; $t=localtime; $r=rand(); print $r, " ", $t->add_years($r);'
0.842100325347023 Fri Apr 14 08:18:52 2017
08:18 ~$ perl -wle 'use Time::Piece; $t=localtime; $r=rand(); print $r, " ", $t->add_years($r);'
0.520783885455788 Wed Dec 14 08:18:55 2016

Also add a note that add_months does NOT also have similar granularity,
08:24 ~$ perl -wle 'use Time::Piece; $t=localtime; $r=-0.5+rand(); print $r, " ", $t->add_months($r);'
0.497017674920247 Tue Jun 14 08:24:38 2016
08:24 ~$ perl -wle 'use Time::Piece; $t=localtime; $r=-0.5+rand(); print $r, " ", $t->add_months($r);'
0.335769493206502 Tue Jun 14 08:24:40 2016
08:24 ~$ perl -wle 'use Time::Piece; $t=localtime; $r=-0.5+rand(); print $r, " ", $t->add_months($r);'
-0.396209953511967 Sat May 14 08:24:42 2016
08:24 ~$ perl -wle 'use Time::Piece; $t=localtime; $r=-0.5+rand(); print $r, " ", $t->add_months($r);'
-0.178354433896853 Sat May 14 08:24:44 2016
its parameter apparently being truncated to an integer.




More information about the Perl-maintainers mailing list