Sha256: 78d78010fa8da3ce604774893a7e102e9cb0c07e5d2799f270da3f74b6585dbc
Contents?: true
Size: 573 Bytes
Versions: 34
Compression:
Stored size: 573 Bytes
Contents
module Kaui module DateHelper LOCAL_DATE_RE = /^\d+-\d+-\d+$/ def format_date(date, timezone="Pacific Time (US & Canada)") # Double check this is not null return nil if date.nil? # If this is a local date we assume this is already in the account timezone, and so there is nothing to do return date.to_s if LOCAL_DATE_RE.match(date.to_s) # If not, convert into account timezone and return the date part only parsed_date = DateTime.parse(date.to_s).in_time_zone(timezone) parsed_date.to_s(:date_only) end end end
Version data entries
34 entries across 34 versions & 1 rubygems