Class: LMSGraphQL::Types::DateTimeType

Inherits:
GraphQL::Schema::Scalar
  • Object
show all
Defined in:
lib/lms_graphql/types/date_time_type.rb

Class Method Summary collapse

Class Method Details

.coerce_input(value, _ctx) ⇒ Object



6
7
8
# File 'lib/lms_graphql/types/date_time_type.rb', line 6

def self.coerce_input(value, _ctx)
  Time.zone.parse(value)
end

.coerce_result(value, _ctx) ⇒ Object



10
11
12
13
14
15
# File 'lib/lms_graphql/types/date_time_type.rb', line 10

def self.coerce_result(value, _ctx)
  if value.is_a? String
    value = Time.zone.parse(value)
  end
  value.utc.iso8601
end