Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Modify TimeWithZone#as_json to return 3DP of sub-second accuracy. #9128
The ISO8601 spec says that decimal fractions may be added for the seconds (actually any) value. The default in recent versions of Firefox, Chrome and Safari (that I have tested) all return 3 decimal places of accuracy for seconds for their default serialisation:
(new Date()).toJSON() "2013-01-31T01:15:22.236Z"
I ran into this in an app using rails-api/active_model_serializers, and initially intended to submit a PR there, but soon discovered that it uses ActiveSupport's default JSON encodings.
It's a very simple change, so I've updated the one test for this method and added a changelog entry. Tests pass on my machine. Please let me know if there's anything I've missed and I'll clean it up immediately.
* master: Skip schema dumper extensions test if connection does not support it active_record: Quote numeric values compared to string columns. Run schema dumper extensions without creating real extensions Do not print anything related to extensions when they don't none exist Add blank line after extensions to separate from tables in schema Fix indentation of extensions in schema Call super to use the abstract adapter implementation instead Add changelog entry for #9203 about schema dumper with db extensions add ActiveRecord::AbstractAdapter#extensions and ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#extensions to allow dumping of enabled extensions to schema.rb, add ActiveRecord::SchemaDumper#extensions to dump extensions to schema.rb improve tests to check for existence of extensions method, and skip testing dumped extensions if they are unsupported by the database Add some tests to enumerate how extensions should be stored in the schema output Update changelog from #9128 with author name Update actionpack/CHANGELOG.md ruby constant syntax is not supported as routing `:controller` option. Fix article for generator name Update .gitignore Enable hstore extensions on tests if it is not enabled and database supports it Ignore .ruby-version Modify TimeWithZone#as_json to return 3DP of sub-second accuracy by default, since it's allowed by the spec and is very useful.
It is odd that only
I suggest that it be configurable and consistent across all the time types.