lazyweb,
do you know if there's a module to parse human readable duration format into seconds, like:
is( parse_duration("3 seconds"), 3 );
is( parse_duration("7 days, 5 hours"), 622800 );
I want to allow users of Plagger to write things like:
fresh: 7 days
in YAML config file, to say "I want fresher entries than 7 days old".
So it's kind of opposite to what Time::Duration does. I know there's DateTime::Format::Duration but it looks like you have to explicitly specify which format you expect and that's not what I want.
Cache::BaseCache module has internally a similar code that I want. Do you think it's worth splitting the functionality to a separate module?
Re:quick code
kasei on 2006-07-17T21:21:33
I was just looking for a module to do this last week. It would be nice if this code found its way onto CPAN.Re:quick code
miyagawa on 2006-07-18T02:25:36
*nod* When I can't come up with the other module that does the exact same thing, I'll name the module Time::Duration::Parse and release to CPAN. Adding L10N support would be interesting (and probably hard).Re:quick code
miyagawa on 2006-07-18T06:47:21
Alright. Time::Duration::Parse is now going to CPAN.
I thought that’s the one sort of thing where Date::Manip (otherwise known as Das Bloat From Hell) is the perfect tool.
Re:Date::Manip?
miyagawa on 2006-07-18T02:24:21
Yeah, I took a look at Date::Manip, too. But there're so many functions defined in the module and couldn't find which function does this. Can u tell me the exact name of the function?Re:Date::Manip?
miyagawa on 2006-07-18T06:11:03
Okay, looks like ParseDateDelta() does very close to what I want, but it's not exactly the same. The function doesn't grok "and" and "," (commas) in the string.