<URL: https://rt.cpan.org/Ticket/Display.html?id=79845 >
On Tue Sep 25 07:27:53 2012, MHASCH wrote: > To demonstrate that the current rounding behaviour is not > quite thought through, try: > > use DateTime 0.76; > my $d = DateTime->new( > year => 2012, > month => 9, > day => 25, > hour => 12, > minute => 39, > second => 59, > nanosecond => 999876000, > time_zone => 'Europe/Berlin', > ); > print $d->strftime('%H:%M:%S.%3N'), "\n"; > > This will print "12:39:59.1000" rather than "12:39:59.999". > And no, please don't make it print "12:40:00.000" either. > Rounding is just not the right thing to do by default. There were a few RT tickets about this and I've thought about it a fair bit. I think your solution is right. This gets really messy with a datetime like 2011-12-31T23:59:59.999 To round properly we'd have to round every single unit, including the year! There's really no way to do this in strftime and format_cldr anyway, since you can only dictate the formatting _per unit_, so you might not even be printing out all the units which need rounding.