Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BTP GeneralizedTime's Leap-second should be "smeared" #481

Closed
sappenin opened this issue Sep 29, 2018 · 3 comments
Closed

BTP GeneralizedTime's Leap-second should be "smeared" #481

sappenin opened this issue Sep 29, 2018 · 3 comments

Comments

@sappenin
Copy link
Contributor

sappenin commented Sep 29, 2018

In IL-RFC-30, the spec mandates that the String value of a leap-second date should BTP-encode to a String that matches its ISO-8601 counterpart (i.e., keep the leap second in each String), like this:

2016-12-31T23.59.60.852Z -> 20161231235960.852Z (leap second)

However, I suggest that the RFC should instead specify that leap-second dates should simply be invalid. As an example, it's unlikely that a system would produce a Timestamp like this: 2016-12-31T23.59.60.852Z

My rationale is as follows:

1. Object Construction in JS & Java

  • Both modern-Java (see Instant.java) and Javascript (see here) "smear" leap seconds into the broader day that includes a leap second. Thus, neither platform actually ever represents a leap-second, but instead smears a portion of the leap-second into the existing seconds of the day, so a day always has 86400 seconds.
  • As an example, doing the following in JS produces a Date that does not contain the leap-second:
new Date('Dec 31 2016 23:59:60 UTC')
Sat, 31 Dec 2016 23:59:00 GMT

2. Parsing

  • Parsing a leap-second value does not work by default in Java, nor in Javascript. For example, see this JSFiddle here where constructing a new Date with the String 2016-12-31T23:59:60.852Z produces an error.
  • Likewise in Java, Instant.parse("2016-12-31T23:59:60.852Z") throws an exception.
  • Also, it's likely that btp-packet is actually broken in this regard when handling leap-seconds per this code here.

3. UTC Standards

  • This above "smearing" or "smoothing" is actually a UTC standard. See UTC-SLS.
@adrianhopebailie
Copy link
Collaborator

Makes sense to me.

@justmoon @emschwartz WDYT? If I recall correctly the choice to use ISO-8601 was to explicitly support leap seconds however I'm not sure if we checked at that time if any OS parsers actually support leap seconds when parsing ISO 8601 format strings like those shown in the examples.

As a side note, I think that section of the IL RFC 30 is out of date as ILP packets no longer use ASN.1 GeneralizedTime.

@justmoon
Copy link
Member

@sappenin Makes sense to me, this was an oversight on my part. Thanks for noticing and the quality research.

@stale stale bot added the wontfix label Nov 9, 2018
@interledger interledger deleted a comment from stale bot Nov 12, 2018
@stale stale bot removed the wontfix label Nov 12, 2018
@stale
Copy link

stale bot commented Dec 12, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is important, please feel free to bring it up on the next Interledger Community Group Call or in the Gitter chat.

@stale stale bot added the wontfix label Dec 12, 2018
@stale stale bot closed this as completed Dec 19, 2018
@sappenin sappenin reopened this Jan 26, 2019
@stale stale bot removed the wontfix label Jan 26, 2019
sappenin added a commit that referenced this issue Jan 26, 2019
* Fixes #480
* Fixes #481

Signed-off-by: sappenin <sappenin@gmail.com>
adrianhopebailie pushed a commit that referenced this issue Feb 11, 2019
* Update OER Encoding of Dates

* Fixes #480
* Fixes #481

Signed-off-by: sappenin <sappenin@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants