On Mon, 16 Dec 2003, Rick Measham wrote: > - The normalisation works for all the tests, but kick it in the shins; > does it really work?
You should handle leap seconds too, otherwise it could be subtly broken when using non-floating datetimes. This isn't that hard. You basically have to check three things: - Number of leap seconds in the base datetime - Number of leap seconds in the datetime of base + duration Then simply add the difference between the two to the normalized seconds value. There's some logic for this in DateTime.pm itself, I believe. - And finally, if the base or base + duration is _on_ a leap second, you may need to represent 60 seconds as "60 seconds", not "1 minute". At least, I think that's all that's needed. > There's a lot in the PODumentation so sorry for the reading, however I > figure it's important to understand the concepts involved. The docs say you support both "normalize" and "normalise", but the code only looks for the latter. I don't see a good reason to set the pattern as part of the object. Why not just do this: my $dur_formatter = DateTime::Format::Duration->new( base => $base, normalize => 1 ); print $dur_formatter->format_duration( duration => $dur, pattern => '%C' ); Having to create a new object for every pattern is just annoying. The parsing methods could work as both class and object methods. All the other DateTime modules divide accessors into setters and getters, so you should probably have ->base and ->set_base (and others) to be consistent. The example formats you use in the docs are a bit confusing since they look so much like actual datetimes. If there's a less ambiguous example format you could use, that'd be good. In the section on "Mixed positivity", you could also note that sometimes 1 day minus 2 hours is _not_ 22 hours, at least in local time. Also, that section might better be called "Mixed Positive and Negative Duration Components". More wordy, but I think it's clearer. Looks like good work. Thanks, -dave /*======================= House Absolute Consulting www.houseabsolute.com =======================*/
