Sha256: a0ec943da507db1b69590e329a9f180e7ce2a016eb210358d95ba60794283a01
Contents?: true
Size: 662 Bytes
Versions: 5
Compression:
Stored size: 662 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 def truncate_millis(date_s) DateTime.parse(date_s).strftime('%FT%T') end end end
Version data entries
5 entries across 5 versions & 1 rubygems