Skip to content

Files

Latest commit

 

History

History
43 lines (30 loc) · 1.08 KB

Rails-TimeZone.md

File metadata and controls

43 lines (30 loc) · 1.08 KB

Pattern: Use of Time method without zone

Issue: -

Description

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.

Examples

# 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

Default configuration

Attribute Value
EnforcedStyle flexible
SupportedStyles strict, flexible

Further Reading