-
Notifications
You must be signed in to change notification settings - Fork 64
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
Handle more time formats and allow custom formats #146
Conversation
06923f8
to
d23e446
Compare
Avram.settings.time_formats.find do |format| | ||
begin | ||
Time.parse(value, format, Time::Location.load("UTC")) | ||
rescue e : Time::Format::Error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish Crystal had some way to return nil
but it only raises when parsing so we have to do this kind of hacky begin/rescue dance :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Working with Time in crystal is actually really clunky.
8d4a795
to
8ca50d2
Compare
8ca50d2
to
775abbb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like the way you coded this up! It's a nice pattern and I'm going to steal it for future projects 😄
Looks good to me! |
Thanks for the reviews. And thanks for the kind words Edward! |
Closes #40