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:


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

def attributes
  ATTRIBUTES
end

#isoString

Returns the ISO8601 time string including milliseconds

Returns:

  • (String)

    the ISO8601 time string including milliseconds


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

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


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

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