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
9
10
# File 'lib/lms_graphql/types/date_time_type.rb', line 6

def self.coerce_input(value, _ctx)
  return if !value

  Time.zone.parse(value)
end

.coerce_result(value, _ctx) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/lms_graphql/types/date_time_type.rb', line 12

def self.coerce_result(value, _ctx)
  return if !value

  if value.is_a? String
    value = Time.zone.parse(value)
  end
  value.utc.iso8601
end