J
Jef Driesen
How can I convert a date string to a number (e.g. a time_t value or a tm
struct)? I know about the strptime function, but then I have to know the
format string. And that is a problem.
I'm trying to autoformat the contents of text entries in a GUI. For
numbers, I'm converting the text representation to the appropriate type
(using atoi, atof, ...) and converting the result back to text with the
correct format (using sprintf). But this does not work for date (or
time) strings.
For instance, if the desired date format is "dd-mm-yy", but the user
enters "dd-mm-yyyy", I can't convert the string to a valid date, because
I don't know its format.
struct)? I know about the strptime function, but then I have to know the
format string. And that is a problem.
I'm trying to autoformat the contents of text entries in a GUI. For
numbers, I'm converting the text representation to the appropriate type
(using atoi, atof, ...) and converting the result back to text with the
correct format (using sprintf). But this does not work for date (or
time) strings.
For instance, if the desired date format is "dd-mm-yy", but the user
enters "dd-mm-yyyy", I can't convert the string to a valid date, because
I don't know its format.