Subject: | DateTime::Format::Duration::ISO8601 doesn't "require DateTime::Duration;" |
Hi!
I'm using DateTime::Format::Duration::ISO8601 directly to parse a string in order to check it's validity.
DateTime::Format::Duration::ISO8601->parse_duration is supposed to return a DateTime::Duration object, but if that module isn't loaded, parse_duration will throw an «Can't locate object method "new" via package "DateTime::Duration" (perhaps you forgot to load "DateTime::Duration"?)» error.
Possible solutions:
1) Update docs example to show that DateTime::Duration also has to be loaded ("require DateTime::Duration;")
2) Add a line with «require DateTime::Duration» somewhere in DT::F::D::ISO8601 where it's appropriate.
3) Don't create a DateTime::Duration object in parse_duration
I'd like to recommend 2) (-:
Also, would you mind adding an is_valid_iso8601_duration method to your module too? (one that just returns false/true values, and doesn't bother loading/creating a DateTime::Duration object).
Thanks,
- Salve
I'm using DateTime::Format::Duration::ISO8601 directly to parse a string in order to check it's validity.
DateTime::Format::Duration::ISO8601->parse_duration is supposed to return a DateTime::Duration object, but if that module isn't loaded, parse_duration will throw an «Can't locate object method "new" via package "DateTime::Duration" (perhaps you forgot to load "DateTime::Duration"?)» error.
Possible solutions:
1) Update docs example to show that DateTime::Duration also has to be loaded ("require DateTime::Duration;")
2) Add a line with «require DateTime::Duration» somewhere in DT::F::D::ISO8601 where it's appropriate.
3) Don't create a DateTime::Duration object in parse_duration
I'd like to recommend 2) (-:
Also, would you mind adding an is_valid_iso8601_duration method to your module too? (one that just returns false/true values, and doesn't bother loading/creating a DateTime::Duration object).
Thanks,
- Salve