c++cwindowslocalecrt

How to parse date string which is formed by the CRT function?


I'm working on a Windows-driven C++ project now. And there is a function which composes a file names with date portion in them. It uses the wcsftime C runtime library function to format the date portion with the "%x" formating code. This code corresponds to the

%x Date representation for the locale

as the documentation says.

Now, I need to check which files match to some dates-range. So, I need to parse this date portion of the file name back to the date and perform the comparing. But, I'm in trouble: how to do this? I didn't find any CRT function which can do the work. Furthermore, it could be much more better for me to get the formating string alike the "dd-mm-yyyy" for the current locale in order to parse this string. But I didn't find any way how to do this.

I pay your attention, that it's about the CRT functions. Its locale differs from the locale used by the GetLocaleInfo, for example.


Solution

  • One easy solution is to go forward : Generate a filename using the same pattern, but for a test date of 2001-02-03. The result will tell you the order of year,month and day.