Sha256: 52500d87eee7c8d357c4d1ac4ab95bb93101a49b28b31c412598ba052e183fac
Contents?: true
Size: 1.22 KB
Versions: 37
Compression:
Stored size: 1.22 KB
Contents
# The string_date_time extension provides String instance methods # for converting the strings to a date (e.g. String#to_date), allowing # for backwards compatibility with legacy Sequel code. class String # Converts a string into a Date object. def to_date begin Date.parse(self, Sequel.convert_two_digit_years) rescue => e raise Sequel.convert_exception_class(e, Sequel::InvalidValue) end end # Converts a string into a DateTime object. def to_datetime begin DateTime.parse(self, Sequel.convert_two_digit_years) rescue => e raise Sequel.convert_exception_class(e, Sequel::InvalidValue) end end # Converts a string into a Time or DateTime object, depending on the # value of Sequel.datetime_class def to_sequel_time begin if Sequel.datetime_class == DateTime DateTime.parse(self, Sequel.convert_two_digit_years) else Sequel.datetime_class.parse(self) end rescue => e raise Sequel.convert_exception_class(e, Sequel::InvalidValue) end end # Converts a string into a Time object. def to_time begin Time.parse(self) rescue => e raise Sequel.convert_exception_class(e, Sequel::InvalidValue) end end end
Version data entries
37 entries across 37 versions & 2 rubygems