[Rails-core] Feature request: Modify TimeWithZone#as_json to take in an option to exclude decimal fractions
Currently the TimeWithZone#as_json always returns 3 decimal points. However, the ISO 8601 standard also supports no decimal point format. It would be great to add an option to the as_json method to not include decimals. This would have several advantages. - By default, it still returns 3 decimal points. This is the widely used (e.g. by major browsers, Chrome, FF, Safari) option. - It would support the no decimal point format part of the ISO 8601 standard. - It allows Rails can communicate with APIs that is expecting no decimal formats when needed. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Core group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.
Re: [Rails-core] Feature request: Modify TimeWithZone#as_json to take in an option to exclude decimal fractions
On Jun 26, 2014, at 12:44 PM, Kirk Chen chen.k...@gmail.com wrote: Currently the TimeWithZone#as_json always returns 3 decimal points. However, the ISO 8601 standard also supports no decimal point format. It would be great to add an option to the as_json method to not include decimals. This would have several advantages. By default, it still returns 3 decimal points. This is the widely used (e.g. by major browsers, Chrome, FF, Safari) option. It would support the no decimal point format part of the ISO 8601 standard. It allows Rails can communicate with APIs that is expecting no decimal formats when needed. This appears to be possible on an application-wide basis as of 4.1.0: https://github.com/rails/rails/commit/c0965004486f2ea5a9656ba718a3377c9614f97d —Matt Jones signature.asc Description: Message signed with OpenPGP using GPGMail