المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : CTime Problem? I don't think so....but who knows?



C++ Programming
09-07-2011, 10:51 AM
We have a print template that replaces generic keywords with specific information, and I've had some reports that the locale specific date format isn't 'taking' on some machines. We have:

if (Key == _T("#CDAT#")){ // Current date - use current users settings for short date CTime time = CTime::GetCurrentTime(); Text = time.Format("%x");}
This appears to work fine on all the machines I've tested it on, under XP, Vista and Win7. But we have a couple of users (one XP, one Win7) that report having to go to the control panel regional settings and 'flip' them, to get the right format in our app. And they report having to do this every time our app is restarted.

To be clear, these users have something like the following scenario:

1) They use the template and see the date come out in English (US) format (mm/dd/yy)
2) They go to regional settings and see that the locale is set to English (New Zealand), and thus the date should be in (dd/mm/yy) format.
3) They flip to English (US) and OK everything.
4) They go back to the settings and flip them back to English (New Zealand). This solves the problem until...
5) Our app is restarted, and steps 1-4 must be repeated.

I'm at a loss to even imagine how this behaviour could occur. There aren't any services or anything that try and 'fix' your locale settings are there? Anyone got any ideas?

Cheers