Pattern: Use of Time
method without zone
Issue: -
This rule checks for the use of Time
methods without zone.
Two styles are supported for this rule. When EnforcedStyle is strict
then only use of Time.zone
is allowed.
When EnforcedStyle is flexible
then it's also allowed
to use Time.in_time_zone
.
# always offense
Time.now
Time.parse('2015-03-02 19:05:37')
# no offense
Time.zone.now
Time.zone.parse('2015-03-02 19:05:37')
# no offense only if style is 'flexible'
Time.current
DateTime.strptime(str, "%Y-%m-%d %H:%M %Z").in_time_zone
Time.at(timestamp).in_time_zone
Attribute | Value |
---|---|
EnforcedStyle | flexible |
SupportedStyles | strict, flexible |