Sha256: 9dc04009a331ade378df8fd87279b44577c2b24aa8f03f4c38422104b60c8668
Contents?: true
Size: 429 Bytes
Versions: 10
Compression:
Stored size: 429 Bytes
Contents
require 'time' DateTime.class_eval do # # Parses the time but never fails. # # A flattened time -- a 12-digit YYYYmmddHHMMMSS -- is treated as a UTC # datetime. # def self.parse_safely dt begin if dt.to_s =~ /\A\d{12}Z?\z/ parse(dt+'Z', true) else parse(dt, true) end rescue nil end end def self.parse_and_flatten str parse_safely(str).to_flat end end
Version data entries
10 entries across 10 versions & 2 rubygems