Skip to content

Writer should use code/iso8601 for date/time/datetime, not inspect - #63

Open
garysweaver wants to merge 1 commit into
mbleigh:masterfrom
garysweaver:writer_encodes_date_time_and_datetime_as_iso8601
Open

Writer should use code/iso8601 for date/time/datetime, not inspect#63
garysweaver wants to merge 1 commit into
mbleigh:masterfrom
garysweaver:writer_encodes_date_time_and_datetime_as_iso8601

Conversation

@garysweaver

Copy link
Copy Markdown

To resolve #43 and #62, this converts Date, Time, DateTime (and ActiveSupport::TimeWithZone if exists) to code that creates a date using the iso8601 version of each time.

This could use some optimization. A much faster way is just to override inspect on Date, Time, DateTime (and ActiveSupport::TimeWithZone if exists) to return "(the class name).iso8601(#{iso8601.inspect})". However, this patch avoids inspect overrides, and it is doubtful most would want inspect overriden. It is ~3x slower than before. (4043 records took 8.1 sec vs. 2.4 sec and 79808 records took 83 sec vs. 30 sec).

Another option might be to use inspect but only temporarily override inspect on the affected classes (Date, Time, etc.), but I'm not absolutely sure that would work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Writer uses inspect to serialize object

1 participant