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

Rails/TimeZone cop should allow Time.parse against a fixed string which includes a timezone specifier (bis) #800

Closed
inkstak opened this issue Oct 5, 2022 · 0 comments · Fixed by #801
Labels
enhancement New feature or request

Comments

@inkstak
Copy link
Contributor

inkstak commented Oct 5, 2022

Is your feature request related to a problem? Please describe.

Similar to #440, we are often use this construct in tests :

Time.parse("2022-10-30 00:00:00 CEST +02:00")

It's especially usefull for explicit summer/winter time :

Time.parse("2022-10-30 00:00:00 CEST +02:00")
 => 2022-10-30 00:00:00 +0200

Time.parse("2022-10-31 00:00:00 CET +01:00")
 => 2022-10-31 00:00:00 +0100

Describe the solution you'd like

If detecting zones abbreviations might be too overwhelming, the cop should be able to detect and allow time offsets from UTC.

Similar to #441 :

-       TIMEZONE_SPECIFIER = /[A-z]/.freeze
+       TIMEZONE_SPECIFIER = /([A-z]|[+-]\d{2}:\d{2})\Z/.freeze

        def attach_timezone_specifier?(date)
-          date.respond_to?(:value) && TIMEZONE_SPECIFIER.match?(date.value.to_s[-1])
+          date.respond_to?(:value) && TIMEZONE_SPECIFIER.match?(date.value.to_s)
        end
inkstak added a commit to inkstak/rubocop-rails that referenced this issue Oct 5, 2022
inkstak added a commit to inkstak/rubocop-rails that referenced this issue Oct 5, 2022
inkstak added a commit to inkstak/rubocop-rails that referenced this issue Oct 5, 2022
@koic koic added the enhancement New feature or request label Oct 5, 2022
inkstak added a commit to inkstak/rubocop-rails that referenced this issue Oct 5, 2022
@koic koic closed this as completed in #801 Oct 6, 2022
koic added a commit that referenced this issue Oct 6, 2022
…mezone_offset

[Fix #800] Make `Rails/TimeZone` aware of timezone offset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants