From: bhaak@... Date: 2014-12-11T09:50:46+00:00 Subject: [ruby-core:66779] [ruby-trunk - Bug #10587] [Open] Time#to_json != DateTime#to_json (Time#to_json not outputting iso8601) Issue #10587 has been reported by Patric Mueller. ---------------------------------------- Bug #10587: Time#to_json != DateTime#to_json (Time#to_json not outputting iso8601) https://bugs.ruby-lang.org/issues/10587 * Author: Patric Mueller * Status: Open * Priority: Low * Assignee: * Category: ext * Target version: * ruby -v: ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN ---------------------------------------- The output of this program is false: ``` require 'date' require 'json' now = Time.now puts now.to_json == DateTime.parse(now.to_s).to_json ``` Testing in IRB shows why: ``` 2.1.5 :004 > now.to_json => "\"2014-12-11 10:34:53 +0100\"" 2.1.5 :005 > DateTime.parse(now.to_s).to_json => "\"2014-12-11T10:34:53+01:00\"" ``` Time#to_json doesn't return an iso8601 conforming string whereas DateTime@to_json does. -- https://bugs.ruby-lang.org/