-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add format option to time field #2029
Conversation
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.
Looking good! Do you think you'll be able to sort the Hound warnings and those with_translations
comments?
cfbe6a7
to
105383f
Compare
@pablobm @amymariewall I think this is ready for another review. I've addressed the linter errors and another issue I spotted: because I18n uses the same key in the locales file for all objects with a time ( |
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 think this looks good; just one comment about use of let
.
spec/lib/fields/time_spec.rb
Outdated
formats: { short: "%H:%M" }, | ||
}, | ||
} | ||
end |
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.
A minor point: we typically avoid using let
in this codebase and prefer to either inline a variable in each it
or extract it into a normal Ruby method.
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.
One more comment; if you change that, feel free to merge it whenever!
spec/lib/fields/time_spec.rb
Outdated
describe "#time" do | ||
before do | ||
@time = DateTime.new(2021, 3, 26, 16, 38) | ||
end |
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.
And before
! I'd just put the DateTime
definition in each it
block.
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.
Sorry, I totally missed the second part of your original comment! 🤦♂️
Previously there was no way to specify format for a time field, but you can specify a format for date and datetime fields. This commit adds the ability to pass a format option to time fields. Because I18n uses the time locale key for for all objects with a time [0], retain the hard-coded time field format where no format option is passed to avoid a breaking change. Addresses issue #1227. [0] https://github.com/ruby-i18n/i18n/blob/0888807ab2fe4f4c8a4b780f5654a8175df61feb/lib/i18n/backend/base.rb#L82 Co-authored-by: Thom Carter <thom.carter@thoughtbot.com>
93fc827
to
55843cc
Compare
Previously there was no way to specify format for a time field, but you can specify a format for date and datetime fields. This commit adds the ability to pass a format option to time fields.
Because I18n uses the time locale key for for all objects with a time, retain the hard-coded time field format where no format option is passed to avoid a breaking change.
Addresses #1227.