-
Notifications
You must be signed in to change notification settings - Fork 709
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
Support ISO 8601 Duration formatting for RTClib's TimeSpan #181
Comments
That sounds like a great addition! |
Without extra context (namely the starting point of the interval), these formats can be ambiguous. “P1M” is supposed to be a one-month duration, but how long is that? 30 days? 31? The Wikipedia article you linked to references the documentation of the Java
|
Yeah, I misspoke above. I meant
I think this would be a good policy for this library as well. Specifically only outputting in days and smaller and failing to parse if the Duration string includes months or larger. I'm comfortable including days because I think it is pretty clear this library doesn't do daylight savings time, but I would be document this behavior in
Yeah, I could, and your overloads are better than my proposed names. I rather dislike overloads because they make FFI to languages without overloads (C, Python, Go, Rust) annoying. How about
Also expect a pull request incoming, where you can make further comments. |
That's an issue. A few of the
You could take that last approach if a specif value of
Indeed. The Arduino IDE (version 1.8.13) passes the flag
Well, in the context of Arduino, I guess only C is concerned. Not sure this should be a concern. From what I have seen, current practice on Arduino seem to be to use overloads. The Arduino core has lots of them. It often calls C from C++, but never the other way around. |
This library provides support for ISO 8601 formatted
DateTime
s through thetoString
andtimestamp
methods, but doesn't have a similar option forTimeSpan
s. ISO 8601 specifies two formats for durations. (Durations appear to be basically the same thing as this library'sTimeSpan
s)I would like to add methods that format
TimeSpan
s according to ISO 8601'sPnYnMnDTnHnMnS
orP<date>T<time>
formats, both a zero allocation version (not sure what to call it, maybeformat
?) and one that returns astd::string
calledtoString
. I would also add aTimeSpan
constructor taking one argument ofconst char *iso8601duration
. Do you think this feature belongs in this library and would you consider merging a PR containing the changes I laid out?The text was updated successfully, but these errors were encountered: