Sha256: 476bd49c8c25f4074ddc1e56e8341abf4375ee96461656ecb4bc23c85e02b581
Contents?: true
Size: 983 Bytes
Versions: 4
Compression:
Stored size: 983 Bytes
Contents
module CloudSesame module Query module AST class DateValue < StringValue COMPILE_FORMAT = '%FT%TZ'.freeze DATETIME_FORMAT = '%FT%T'.freeze DATE_FORMAT = '%F'.freeze def self.parse(value) return value.parse self if value.kind_of?(RangeValue) range?(value) || string_range?(value) ? RangeValue.new(value, self) : string_datetime?(value) ? new(parse_datetime(value)) : string_date?(value) ? new(parse_date(value)) : new(value) end def to_s compile end private def self.parse_datetime(string) DateTime.strptime(string, DATETIME_FORMAT) end def self.parse_date(string) Date.strptime(string, DATE_FORMAT) end def recompile(value) super strip format value end def format(value) value.strftime COMPILE_FORMAT end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems