DateTime: Locale to ISO 8601

@karolus your code does not handle user-supplied datetime string in arbitrary locale properly. You would have to differentiate between MD and DM variants…

of course, but it is just an example of »it can handle any formatted-date as long the user has a clue about its meaning and is able to set the proper values.

Relying on user having any clue is the first programmer’s mistake :slight_smile:

If you mean the user of the strptime (a Python developer), then it’s more difficult. As I understand @Lupp’s goal, the idea is to allow any user throughout the world to enter dates in their preferred format, and try to obtain the date from their input, at least most of the time, and with minimal surprise. Providing a locale is ~trivial (at least we can obtain it from the program settings), while providing a format string may be impossible for the programmer.

And here we do exactly what @Lupp asked for: we reuse the code that tries to convert user input into numbers - exactly the same code that is used e.g. in Calc to process numbers entered in formula bar.

Exactly.
I’m overwhelmed by the interest of both of you.
Even based on the advice given “far above” it had taken me hours to get a working function using a service I had never worked with before.
The complete Basic Code posted by @mikekaganski is simply great.

I think in the Basic style there would be a function that returns a Variant variable of subtype Date, Empty on error.
It would probably be useful to have such a function in LO.
@mikekaganski , thank you very much!