Class: Date

Inherits:
Object show all
Includes:
ActiveSupport::CoreExtensions::Date::Behavior, ActiveSupport::CoreExtensions::Date::Calculations, ActiveSupport::CoreExtensions::Date::Conversions
Defined in:
lib/active_support/core_ext/date.rb,
lib/active_support/json/encoders/date.rb

Overview

:nodoc:

Constant Summary

Constants included from ActiveSupport::CoreExtensions::Date::Conversions

ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMATS

Instance Method Summary collapse

Methods included from ActiveSupport::CoreExtensions::Date::Conversions

included, #readable_inspect, #to_date, #to_datetime, #to_formatted_s, #to_time, #xmlschema

Methods included from ActiveSupport::CoreExtensions::Date::Calculations

#advance, #ago, #beginning_of_day, #beginning_of_month, #beginning_of_quarter, #beginning_of_week, #beginning_of_year, #change, #end_of_day, #end_of_month, #end_of_quarter, #end_of_week, #end_of_year, included, #last_month, #last_year, #minus_with_duration, #months_ago, #months_since, #next_month, #next_week, #next_year, #plus_with_duration, #since, #tomorrow, #years_ago, #years_since, #yesterday

Methods included from ActiveSupport::CoreExtensions::Date::Behavior

#acts_like_date?

Instance Method Details

#to_json(options = nil) ⇒ Object

Returns a JSON string representing the date.

Example:

Date.new(2005,2,1).to_json
# => "2005/02/01"


7
8
9
10
11
12
13
# File 'lib/active_support/json/encoders/date.rb', line 7

def to_json(options = nil)
  if ActiveSupport.use_standard_json_time_format
    %("#{strftime("%Y-%m-%d")}")
  else
    %("#{strftime("%Y/%m/%d")}")
  end
end