digivet-consortium / movenet

Generating network representations for livestock movement (and associated) data
https://digivet-consortium.github.io/movenet/
GNU General Public License v3.0
2 stars 3 forks source link

Validate_config_datatype() + change_config(): improve date format testing #68

Closed CarlijnB closed 1 year ago

CarlijnB commented 1 year ago

Date format testing in these options currently works by identifying whether the strings include any of "%(Y|y|AD|D|F|x|s)|^$". This is only approximate.

Probably better to replace with a try_catch() around some readr date-reading function.

CarlijnB commented 1 year ago

This is complicated: while there are a limited number of "date components" (prefixed by %), readr accepts any additional combination of characters, as "Any other character [not part of a date component] is matched exactly". I don't think there's a way of testing whether date formats make sense (e.g. writing to a specific format). Extended test to grepl("%(Y|y|m|b|B|AD|D|F|x|s)|^$",""), to allow for a year being added as characters rather than %Y or %y