Class: ActiveReporter::Dimension::Time::Set

Inherits:
Bin::Set
  • Object
show all
Defined in:
lib/active_reporter/dimension/time.rb

Instance Method Summary collapse

Methods inherited from Bin::Set

#==, #[], #as_json, #bin_edges, #bin_text, #cast_bin_text, #contains_sql, from_hash, from_sql, #has_key?, #hash, #initialize, #inspect, #max, #min, #parses?, #quote, #row_sql, #valid?, #values_at

Constructor Details

This class inherits a constructor from ActiveReporter::Dimension::Bin::Set

Instance Method Details

#cast(value) ⇒ Object



84
85
86
87
88
89
90
91
92
93
# File 'lib/active_reporter/dimension/time.rb', line 84

def cast(value)
  case ActiveReporter.database_type
  when :postgres
    "CAST(#{super} AS timestamp with time zone)"
  when :sqlite
    "DATETIME(#{super})"
  else
    "CAST(#{super} AS DATETIME)"
  end
end

#parse(value) ⇒ Object



80
81
82
# File 'lib/active_reporter/dimension/time.rb', line 80

def parse(value)
  ::Time.zone.parse(value.to_s.gsub('"', ""))
end