Skip to content

Conversation

@PaulWessel
Copy link
Member

While desirable, it is just not possible to expect random people to pay attention to ISO format specifications, so they give dd/mm/yyyy while we expect yyyy-mm-dd. This PR tries a bit harder in gmtio_examine_current_record to determine what we have and update the template if needed. If the user have set FORMAT_DATE_IN then we do not change it, but if it is set to the default ISO template (yyyy-mm-dd) then we check if a candidate absolute date-time input can work with that or if we got something else, e.g., dd/mm/yyyy or dd-monthname-yyyy and need to rebuild the active FORMAT_DATE_IN format.

@joa-quim, have a look at the gmtio_check_abstime_format_is_suitable function in gmt_io.c. It should catch most common things but not idiocy like OCT-2001-11, but we could add even that...

Just not possible to expect randomw people to pay attantion to ISO format specifications, so they give dd/mm/yyyy while we expect yyyy-mm-dd.  This PR tries a bit harder in gmtio_examine_current_record to determine what we have and update the template if needed.
@PaulWessel PaulWessel added the enhancement Improving an existing feature label Oct 13, 2023
@PaulWessel PaulWessel added this to the 6.5.0 milestone Oct 13, 2023
@PaulWessel PaulWessel requested a review from joa-quim October 13, 2023 18:45
@PaulWessel PaulWessel self-assigned this Oct 13, 2023
@PaulWessel
Copy link
Member Author

(base) pwessel@MacAttack-2:~-> gmt info enso_new.txt
enso_new.txt: N = 1824	<1870-01-01T00:00:00/2021-12-01T00:00:00>	<-2.49/2.57>
(base) pwessel@MacAttack-2:~-> gmt info enso_new.txt --FORMAT_DATE_IN=yyyy/mm/dd
enso_new.txt: N = 1824	<1870-01-01T00:00:00/2021-12-01T00:00:00>	<-2.49/2.57>

echo 21-JAN-2006 | gmt convert
2006-01-21T00:00:00
echo 2006-JAN-21 | gmt convert
2006-01-21T00:00:00
echo 12-12-2019 | gmt convert
2019-12-12T00:00:00

@PaulWessel PaulWessel changed the title WIP Try harder to guess date format and update template Try harder to guess date format and update template Oct 13, 2023
@PaulWessel PaulWessel merged commit 6aebdea into master Oct 13, 2023
@PaulWessel PaulWessel deleted the better-date-guessing branch October 13, 2023 20:59
@maxrjones maxrjones added the add-changelog Add PR to the changelog label Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

add-changelog Add PR to the changelog enhancement Improving an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants