Class: Parse::Date
- 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
- #attributes ⇒ Hash
-
#iso ⇒ String
The ISO8601 time string including milliseconds.
- #parse_class ⇒ Parse::Model::TYPE_DATE (also: #__type)
-
#to_s(*args) ⇒ String
The ISO8601 time string including milliseconds.
Methods inherited from DateTime
Class Method Details
.parse_class ⇒ Parse::Model::TYPE_DATE
32 |
# File 'lib/parse/model/date.rb', line 32 def self.parse_class; Parse::Model::TYPE_DATE; end |
Instance Method Details
#iso ⇒ String
Returns 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_class ⇒ Parse::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.
48 49 50 |
# File 'lib/parse/model/date.rb', line 48 def to_s(*args) args.empty? ? iso : super(*args) end |