On Mon, 28 Jul 2008, Dan Muey wrote:
Thanks for the feedback, I've replied inline below. Please let me know if you
have any other questions or suggestions.
On Jul 27, 2008, at 4:12 PM, Dave Rolsky wrote:
On Sun, 27 Jul 2008, Flavio S. Glock wrote:
re:
http://search.cpan.org/dist/DateTime-Format-Span/
This module seems to handle durations, instead of spans.
A duration is span of time no? This module uses 'span' to mean 'the duration
of time spanning 2 points in time' (plus ::Duration was taken)
Right, the confusion is that there is a DateTime::Span class, and I'd
expect DateTime::Format::Span to take an object of that class and format
it.
However, your module only operates on durations. Even more confusingly, it
offers a "format_duration" method which only accepts a single duration,
which is _not_ a span.
This really is not a good name for your module, because of this reason.
The real difference is that it is simply not how a human would say it.
For example from ::Duration's POD regarding its output:
3 years, 5 months, 1 days, 6 hours, 15 minutes, 45 seconds
For English:
a) '1 days' should be '1 day'
b) 45 seconds should be 'and 45 seconds' (keeping the oxford comma)
In my original draft I sent to Dave, when it was not under DateTime::Format
like it should have been, I had this in an FAQ, I should probably add it
back,
Why didn't you just use 'DateTime::Format::Duration'
Essencially it is a strftime for a Duration. This is not flexible enough for
the intent of this module.
DateTime::Format::Duration is not a bad module its just for a different
purpose
It was not localizable
You either got '2 days' or '1 days' which a) forces it to be in English and
b) doesn't even make sense in English.
You could get around that by adding logic each time you wanted to call it but
that is just messy.
Had to keep an item even if it was zero
If 'days' was in there you got '0 days', we only want items with a value to
show.
That'd also require a lot of logic each time you wanted to call which is
again messy.
This all seems like it could go into DT::F::Duration though, just with
different strftime-type specifiers (or CLDR, or whatever).
As far as localization, I'd prefer to see locale-specific data as part of
the DateTime::Locale module itself. In fact, CLDR 1.6 does include a bunch
of stuff for formatting spans in a locale-specific way. I haven't
integrated that into DT::Locale yet, because I want to figure out how to
actually use it.
That'd be great! The way I did this for now was that ::Span::Locale
determined what locale to use based on the datetime object's and/or args then
loads Span::Locale::XX if possible and uses the data it defines.
Some of the information you define in the locale modules does exist in
CLDR, notably singular versions of things like "day", "month", etc.
CLDR also includes formats for doing things like formatting a span based
on the "greatest unit of differnece" between two dates. It's rather
complicated, so I haven't implemented it yet. Basically, it lets you
format something intelligently so you get "Jan 10-12" vs "Jan 10 - Feb
10".
-dave
/*==========================
VegGuide.Org
Your guide to all that's veg
==========================*/