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

DateOnly data example is not compatible to RFC 3339, section 5.6 #190

Closed
jarosmpost opened this issue Jan 24, 2022 · 5 comments
Closed

DateOnly data example is not compatible to RFC 3339, section 5.6 #190

jarosmpost opened this issue Jan 24, 2022 · 5 comments

Comments

@jarosmpost
Copy link

DateOnly is not compliant with RFC 3339, section 5.6, because the time zone is missing. It is not clear at what moment the change from one day to another happens.

@hiddenalpha
Copy link
Member

hiddenalpha commented Jan 24, 2022

Works perfectly fine here when using generated Java classes:

grafik

Maybe only affects .Net stuff?

@jarosmpost
Copy link
Author

From https://github.com/swisspush/apikana/blob/develop/src/model/ts/default-types.ts:

/**
* <a href="https://swagger.io/docs/specification/data-models/data-types/#string">String @format date</a>,
* as defined by <a href="https://tools.ietf.org/html/rfc3339#section-5.6">RFC 3339, section 5.6</a>,
* for example: <code>2017-07-21</code>.
*/
export type DateOnly=string // @format date

The example is only 'yyyy-mm-dd' without time zone and this not compatible to RFC 3339, section 5.6.

@jarosmpost jarosmpost changed the title DateOnly is not compatible to RFC 3339, section 5.6 DateOnly data example is not compatible to RFC 3339, section 5.6 Jan 24, 2022
@hiddenalpha
Copy link
Member

hiddenalpha commented Jan 24, 2022

Ah :) I missed that. We've a DateOnly not a DateTime as I thought.


(Edit: BTW: If a type representing "date-time" (eg including date, time and offset) is wanted, DateTime could be used which contains everything needed. this type would cover the full type of the named RFC)


Unluckily with DateOnly I guess the situation gets a bit trickier I think :|

Originally "DateOnly" was clearly defined to be the "full-date" part named in the linked spec. (See older default-types.ts). This way, the format "YYYY-mm-dd" even is the only valid format. As its definition was unmistakable (cited from RFC):

   ...
   date-fullyear   = 4DIGIT
   date-month      = 2DIGIT  ; 01-12
   date-mday       = 2DIGIT  ; 01-28, 01-29, 01-30, 01-31 based on
                             ; month/year
   ...
   full-date       = date-fullyear "-" date-month "-" date-mday
   ...

So there's neither timezone nor offset information involved in the "full-date" type. I've no idea why this detail got dropped from Apikana doc somewhen later.


Nevertheless I think the remaining question is: What is the correct way to store a DateOnly but including offset information. Actually I don't know such a format.

We usually only use "DateTime" even we're not interested in the time part. This might be the reason we never stumbled over this yet.

@lbovet
Copy link
Member

lbovet commented Jan 25, 2022

DateOnly is precisely meant to refer to a date and not a point in time (datetime). The timezone is irrelevant.
It is not intended to be deserialized as a datetime but as a date. E.g. java.time.LoclalDate in Java.

@jarosmpost
Copy link
Author

@lbovet : Okay. That's a good clue. I make a suggestion to improve the comment for DateOnly: #191.

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

No branches or pull requests

3 participants