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. One important note with dates, is that ‘created_at’ and ‘updated_at’ columns do not follow this convention all the time. Depending on the Cloud Code SDK, they can be the Parse ISO hash date format or the iso8601 string format. By default, these are serialized as iso8601 when sent as responses to Parse for backwards compatibility with some clients. To use the Parse ISO hash format for these fields instead, set ‘Parse::Object.disable_serialized_string_date = true`.

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



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

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

Instance Method Details

#attributesHash

Returns:



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

def attributes
  ATTRIBUTES
end

#isoString

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 iso
  to_time.utc.iso8601(3)
end

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



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

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



48
49
50
# File 'lib/parse/model/date.rb', line 48

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