Class: Date

Inherits:
Object show all
Includes:
ActiveSupport::CoreExtensions::Date::Behavior, ActiveSupport::CoreExtensions::Date::Calculations, ActiveSupport::CoreExtensions::Date::Conversions
Defined in:
lib/gems/activesupport-2.2.2/lib/active_support/core_ext/date.rb,
lib/gems/activesupport-2.2.2/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, #future?, included, #last_month, #last_year, #minus_with_duration, #months_ago, #months_since, #next_month, #next_week, #next_year, #past?, #plus_with_duration, #since, #today?, #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. If ActiveSupport.use_standard_json_time_format is set to true, the ISO 8601 format is used.

Examples:

# With ActiveSupport.use_standard_json_time_format = true
Date.new(2005,2,1).to_json
# => "2005-02-01"

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


14
15
16
17
18
19
20
# File 'lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/date.rb', line 14

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