-
Notifications
You must be signed in to change notification settings - Fork 6
Use ISO8601 as the DPN date-time format #128
base: develop
Are you sure you want to change the base?
Conversation
16b7273
to
7ea5521
Compare
@Pcolar - does the DPN specification use ISO8601 for date formats? If not, what? Where is it defined? I assume it is defined somewhere, but have not yet found the details, e.g.
This page does not explicitly identify ISO8601 as the DPN date-time standard: |
Date fields in DPN use ISO 8601. That was decided during the initial design and documented: last_fixity_date: ISO 8601 |
I think the confusion is arising because there are many iso8601 date formats. |
So long as the implementation can parse/return any of the iso8601 formats, it complies with the specification. Is there an additional requirement to use only a subset of the iso8601 formats? If so, should we elaborate on the reasons for that? With regard to implementation details, it may help to look at the ruby API used, e.g. |
In this PR, the # File activesupport/lib/active_support/time_with_zone.rb, line 134
def xmlschema(fraction_digits = 0)
fraction = if fraction_digits.to_i > 0
(".%06i" % time.usec)[0, fraction_digits.to_i + 1]
end
"#{time.strftime("%Y-%m-%dT%H:%M:%S")}#{fraction}#{formatted_offset(true, 'Z')}"
end Copied from http://apidock.com/rails/ActiveSupport/TimeWithZone/xmlschema |
iirc it originally came from wanting compatibility between all implementations, though even that I'm not clear on (or why it would be necessary since a good DateTime library should handle everything). Other than that using utc 0 as the time zone seems to be mostly for convenience reasons - like spot checking dates when testing and the like. |
This will need to be rebased and revised to adjust to the changes now merged from #125 |
8027aa7
to
57c17e3
Compare
|
Some parsing of the input data is not part of the active support library. Unit tests are needed to demonstrate this use case. |
map_from_public public_field do |value| | ||
{model_field => time_from_public(value)} | ||
end | ||
map_to_public model_field do |value| | ||
{public_field => value.strftime(date_format)} | ||
{public_field => value.iso8601} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although there were no problems in the specs, possibly because they are using the same method, this may not be correct. It might need to be modified to first ensure it is a UTC time, e.g.
[21] pry(BagAdapter)> Time.now.iso8601
=> "2016-10-31T13:46:26-07:00"
[22] pry(BagAdapter)> Time.now.utc.iso8601
=> "2016-10-31T20:46:34Z"
If this PR were adopted, some commit squashing can be done to tidy it up. Leaving them as separate commits while this PR is open for review, in case there is discussion about using one or another alternative implementation. |
Exploring an alternative solution to #124 (cf. #125); may also fix #131
This solution focuses on using the ISO8601 datetime format. The last commit ensures it, but if the date format must or should be a parameter, the last commit can be dropped.
http://www.iso.org/iso/home/standards/iso8601.htm