Win32: GetDateFormat and GetTimeFormat exist. GetDateTimeFormat?

I know that Win32 has an Nls GetDateFormat function, for example:

GetDateFormat(…, …, …, "dddd','MM','y", …, …); 

and GetTimeFormat , for example:

 GetTimeFormat(…, …, …, "tt ss':'hh':'mm", …, …); 

But is there a way to format both points, for example:

 GetDateTimeFormat(…, …, …, "tt dddd' - 'ss':'y';'hh':'mm MM", …, …); 

Note. A format string is intentionally designed to demonstrate that not all format strings are linearly split.

+4
source share
1 answer

I remember that once there was the same problem. Unfortunately, there is no easy way to format a string with mixed date and time fields. An attempt to do this in two stages is a tendency to mistakes, since the first substitution can generate words whose letters are mistaken for format codes.

My solution at that time was to manually scan the format string and generate output by calling GetDateFormat() and GetTimeFormat() for each code. This can be optimized by grouping consecutive time or date codes, if necessary.

+2
source

Source: https://habr.com/ru/post/1303964/


All Articles