Class: ClickHouse::Type::DateTime64Type

Inherits:
BaseType
  • Object
show all
Defined in:
lib/click_house/type/date_time64_type.rb

Instance Method Summary collapse

Methods inherited from BaseType

#cast_each, #container?, #ddl?, #map?, #serialize_each, #tuple?

Instance Method Details

#cast(value, _precision = nil, tz = nil) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/click_house/type/date_time64_type.rb', line 6

def cast(value, _precision = nil, tz = nil)
  if tz
    Time.find_zone(tz).parse(value)
  else
    Time.parse(value)
  end
end

#serialize(value, precision = 3, _tz = nil) ⇒ Object



14
15
16
# File 'lib/click_house/type/date_time64_type.rb', line 14

def serialize(value, precision = 3, _tz = nil)
  value.strftime("%Y-%m-%d %H:%M:%S.%#{precision}N")
end