You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The constructor DateTime(const char *iso8601dateTime) claims to enable the creation of DateTime objects using an ISO8601 date time definition.
However, the constructor only works for iso datetimes of format: "2000-01-01T00:00:00" that can be truncated from the right at an arbitrary position, e.g. the string "2000-01" leads to a valid result.
This can be seen from the constructor implementation in the code:
Other definitions (https://en.wikipedia.org/wiki/ISO_8601#Times) like times only, e.g. T18:00, do not work. It is necessary to always define a full date with year, month and day before a time can be specified. Further, the colon between hours and minutes is mandatory for the constructor to work correctly. This is not the case in the ISO standard.
The text was updated successfully, but these errors were encountered:
Dear edgar-bonet, thank you for your (incredibly) fast answer and your work in the pull request.
From my point of view, this is of great help to prevent misunderstanding in the future.
As you mentioned, it does not make sense to use a DateTime class object as defined in the library for anything else than a full date at the moment. Storing only time values is not meaningful.
However, this might not be clear at first glance when looking at the current documentation, as a DateTime objects defaults to the reference:
char ref[] = "2000-01-01T00:00:00";
and a user (as me) would come to the idea of living with the default year, month and day and storing only time information.
Your pull request helps here.
From my point of view, the issue is closed.
However one might think in the future of allowing all ISO 8601 specifiers, and point the user to the fact that default values for not specified items are used as in the current ref string. The user then can decide on how to treat the defaults on his own.
This should be mentioned in the documentation then as well.
The constructor DateTime(const char *iso8601dateTime) claims to enable the creation of DateTime objects using an ISO8601 date time definition.
However, the constructor only works for iso datetimes of format:
"2000-01-01T00:00:00" that can be truncated from the right at an arbitrary position, e.g. the string "2000-01" leads to a valid result.
This can be seen from the constructor implementation in the code:
(RTClib.cpp, line 369)
Other definitions (https://en.wikipedia.org/wiki/ISO_8601#Times) like times only, e.g. T18:00, do not work. It is necessary to always define a full date with year, month and day before a time can be specified. Further, the colon between hours and minutes is mandatory for the constructor to work correctly. This is not the case in the ISO standard.
The text was updated successfully, but these errors were encountered: