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.
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
26 | # File 'lib/parse/model/date.rb', line 26 def self.parse_class; Parse::Model::TYPE_DATE; end |
Instance Method Details
#iso ⇒ String
Returns 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_class ⇒ Parse::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.
43 44 45 | # File 'lib/parse/model/date.rb', line 43 def to_s(*args) args.empty? ? iso : super(*args) end |