Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Time::Piece with DateTime #461

Closed
preaction opened this issue Feb 13, 2016 · 4 comments
Closed

Replace Time::Piece with DateTime #461

preaction opened this issue Feb 13, 2016 · 4 comments

Comments

@preaction
Copy link
Owner

The Time::Piece module is based on the tm struct of the underlying OS. This can result in complications, including an inability to parse date/time before 1900-01-01.

The DateTime module can correctly express dates and times in any range. It is pure-Perl, so easily installed. Instead of using Time::Piece, we should switch to DateTime for our internal date representations.

This may be a breaking change. Worse, it may be a breaking change in the templates, since some templates require the use of formatted date and time. If this is a breaking change, if possible, we should try to smooth the process with a wrapper class (like Statocles::DateTime or something).

@preaction preaction added the bug label Feb 13, 2016
@preaction preaction added this to the v1.000 milestone Feb 13, 2016
@kentfredric
Copy link
Contributor

I'd probably discourage DateTime to some extent, as it has some API choices that can't be removed and are footguns.

https://rjbs.manxome.org/rubric/entry/1929
http://blog.plover.com/prog/perl/DateTime-Moonpig.html
https://metacpan.org/pod/DateTime::Moonpig

Or something similarly sensible would be recommended.

@preaction
Copy link
Owner Author

Yeah, but DateTime::Format::Strptime doesn't make DateTime::Moonpig objects... DateTime::Tiny can't format. Date::Parse suffers the same bug as Time::Piece. Is there something simple and not terrible that can strftime and strptime and support an encyclopedia of dates?

I'm of the opinion that only ISO8601 dates should be accepted as input by Statocles, and that's easy enough to parse, so I think I'll try getting DateTime::Moonpig objects in there. It's only an accident of history that we have to output other date formats (RSS uses RFC822 dates, why?).

@preaction
Copy link
Owner Author

DateTime::Moonpig / DateTime do not have the tzoffset method. Instead they have a better offset method. This requires changing the feed templates. Anyone who upgrades will get exceptions about a missing tzoffset method.

@preaction
Copy link
Owner Author

I could install a DateTime::Moonpig::tzoffset method as a temporary measure (warning when it is used) to smooth the transition...

preaction added a commit that referenced this issue Feb 18, 2016
This should allow users time to fix their templates, along with
instructions on how to do so.

Refs #461
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants