Add support for meridian indicators on Date objects#640
Merged
radar merged 1 commit intoruby-i18n:masterfrom Nov 13, 2022
Merged
Add support for meridian indicators on Date objects#640radar merged 1 commit intoruby-i18n:masterfrom
Date objects#640radar merged 1 commit intoruby-i18n:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What are you trying to accomplish?
Fixes #639
What approach did you choose and why?
Assume that the
hourof aDateis always0. Reading the source forDate, it seems thathouris set to0and cannot be changed, regardless of how you create theDate.My higher-level attempts also failed to set it to anything (adding confidence that I didn't misread the source. For example:
localizeis only meant forDate,DateTime, andTimeobjects anyway, so I'm not concerned. Besides, if one were to pass in a different object intolocalizethat didn't respond tohour, then defaulting to 0 would be consistent with the values used in other date libraries. 🤷What should reviewers focus on?
Is there a better way to do this?
Another way to do this would be to bypass the private method safety for
Dateobjects by usingsend:Technically this would run the risk of Ruby changing the private implementation of
Date#hour, but that feels like it could be an acceptable risk to me?I mostly chose the 0 defaulting way since it felt cleaner and didn't rely on
send, but I have no strong preferences either way. I'm happy to change it if people feel strongly otherwise.The impact of these changes
Formats with Meridian indicators will once again work with
Dateobjects.