My application reads a csv file provided by the user. This csv file contains a field for date and / or time, formatted in any way the user chose it. Like: 1999/10/28 or 2000-01-01,3PM-02-59
I want to offer the user the possibility to indicate the formatting of the date and time in this field. So, I'd have an input window saying: "Specify the formatting of your date/time field" "Example: for 1999/10/28 format, input yyyy/mm/dd" "Other example: for 2000-01-01,3PM-02-59,input yyyy-dd-mm,hh-mm-ss"
I would retrieve their input as a string, then do some complicated and annoying operation to derive a regular expression from this string, which I would then apply in the csv parser to identify years, months, days, hours, etc. in the "date and time" field.
My question before embarking in this: is there a library which already does this kind of thing? Am I reinventing the wheel? Is there a much more obvious approach I'm missing?
Thanks a lot!
PS: yes, it is all about users providing their own strange date and time formats. No need to suggest that it would be easier with a a uniform format! :-)