mentorenwahl/backend/src/backend/api/schema/scalars/time.cr

18 lines
354 B
Crystal

module Backend::Api::Schema::Scalars
@[GraphQL::Scalar]
class Time < GraphQL::BaseScalar
property value
def initialize(@value : ::Time)
end
def self.from_json(string_or_io)
self.new(::Time.parse_iso8601(string_or_io))
end
def to_json(builder : JSON::Builder)
builder.scalar(@value.to_rfc3339)
end
end
end