Sha256: 27c096dc8732ee944070577e729d5616a17c3ea90a07796fb8b0f88f2ecea8f8
Contents?: true
Size: 622 Bytes
Versions: 3
Compression:
Stored size: 622 Bytes
Contents
class String # Form can be either :utc (default) or :local. def to_time(form = :utc) return nil if self.blank? Timeliness::Parser.parse(self, :datetime, zone: form) end def to_date return nil if self.blank? values = Timeliness::Parser._parse(self, :date).map { |arg| arg || 0 } ::Date.new(*values[0..2]) end def to_datetime return nil if self.blank? values = Timeliness::Parser._parse(self, :datetime).map { |arg| arg || 0 } values[7] = values[7]/24.hours.to_f if values[7] != 0 values[5] += Rational(values.delete_at(6), 1000000) ::DateTime.civil(*values) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
timeliness-0.5.0 | lib/timeliness/core_ext/string.rb |
timeliness-0.4.5 | lib/timeliness/core_ext/string.rb |
timeliness-0.4.4 | lib/timeliness/core_ext/string.rb |