Class: Parse::Date

Inherits:
DateTime show all
Includes:
ActiveModel::Model, ActiveModel::Serializers::JSON
Defined in:
lib/parse/model/date.rb

Overview

This class manages dates in the special JSON format it requires for properties of type :date.

Constant Summary collapse

ATTRIBUTES =

The default attributes in a Parse Date hash.

{ __type: :string, iso: :string }.freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DateTime

#parse_date

Class Method Details

.parse_classParse::Model::TYPE_DATE


26
# File 'lib/parse/model/date.rb', line 26

def self.parse_class; Parse::Model::TYPE_DATE; end

Instance Method Details

#attributesHash

Returns:


33
34
35
# File 'lib/parse/model/date.rb', line 33

def attributes
  ATTRIBUTES
end

#isoString

Returns the ISO8601 time string including milliseconds.

Returns:

  • (String)

    the ISO8601 time string including milliseconds


38
39
40
# File 'lib/parse/model/date.rb', line 38

def iso
  to_time.utc.iso8601(3)
end

#parse_classParse::Model::TYPE_DATE Also known as: __type


28
# File 'lib/parse/model/date.rb', line 28

def parse_class; self.class.parse_class; end

#to_s(*args) ⇒ String

Returns the ISO8601 time string including milliseconds.

Returns:

  • (String)

    the ISO8601 time string including milliseconds


43
44
45
# File 'lib/parse/model/date.rb', line 43

def to_s(*args)
  args.empty? ? iso : super(*args)
end