aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/json
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-05-18 21:20:35 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-05-18 21:20:35 +0000
commitfd15359104afbdf86f86a1c1f9b424b855fb3071 (patch)
tree3338bc227030570f2bd899424a3ebbf4301691ae /activesupport/lib/active_support/json
parentd2acf8b548b56966da49bd7f2f92dcfbd5410319 (diff)
downloadrails-fd15359104afbdf86f86a1c1f9b424b855fb3071.tar.gz
rails-fd15359104afbdf86f86a1c1f9b424b855fb3071.tar.bz2
rails-fd15359104afbdf86f86a1c1f9b424b855fb3071.zip
Date, Time, and DateTime#to_json. Closes #8399.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6773 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support/json')
-rw-r--r--activesupport/lib/active_support/json/encoders/date.rb5
-rw-r--r--activesupport/lib/active_support/json/encoders/date_time.rb5
-rw-r--r--activesupport/lib/active_support/json/encoders/time.rb5
3 files changed, 15 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/json/encoders/date.rb b/activesupport/lib/active_support/json/encoders/date.rb
new file mode 100644
index 0000000000..ee1a472f3f
--- /dev/null
+++ b/activesupport/lib/active_support/json/encoders/date.rb
@@ -0,0 +1,5 @@
+class Date
+ def to_json #:nodoc:
+ %("#{strftime("%m/%d/%Y")}")
+ end
+end
diff --git a/activesupport/lib/active_support/json/encoders/date_time.rb b/activesupport/lib/active_support/json/encoders/date_time.rb
new file mode 100644
index 0000000000..28cb18977d
--- /dev/null
+++ b/activesupport/lib/active_support/json/encoders/date_time.rb
@@ -0,0 +1,5 @@
+class DateTime
+ def to_json #:nodoc:
+ %("#{strftime("%m/%d/%Y %H:%M:%S %Z")}")
+ end
+end
diff --git a/activesupport/lib/active_support/json/encoders/time.rb b/activesupport/lib/active_support/json/encoders/time.rb
new file mode 100644
index 0000000000..080e9392f1
--- /dev/null
+++ b/activesupport/lib/active_support/json/encoders/time.rb
@@ -0,0 +1,5 @@
+class Time
+ def to_json #:nodoc:
+ %("#{strftime("%m/%d/%Y %H:%M:%S %Z")}")
+ end
+end