Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 449
  • Last Modified:

CTime::Format() and regional settings

Is there a way to access the Windows time/date regional settings when you are creating a format string?  For instance, my date format might be "4 Aug 98" but someone in the States might use "8/4/1998."  and it seems the same code ought to figure this out and adjust its results.
0
standefe
Asked:
standefe
  • 3
1 Solution
 
psdavisCommented:
Sure.  There's a whole system of 'locales' to deal with this.  Try:

GetDateFormat  
The GetDateFormat function formats a date as a date string for a specified locale. The function formats either a specified date or the local system date.

int GetDateFormat( LCID Locale,
 // locale for which date is to be formatted
 
DWORD dwFlags,
 // flags specifying function options
 
CONST SYSTEMTIME *lpDate,
 // date to be formatted
 
LPCTSTR lpFormat,
 // date format string
 
LPTSTR lpDateStr,
 // buffer for storing formatted string
 
int cchDate
 // size of buffer
 
);

Phillip  



0
 
psdavisCommented:
There's a real good discussion in the 'Going Global' site from Microsoft.

http://www.windows.com/globaldev/gbl-gen/nlsuppor.htm


0
 
psdavisCommented:
And another with an example on how to display today's date in the current locale.  There's also a small sample code at the site as well.

http://www.windows.com/globaldev/gbl-gen/nls.htm

Also, don't forget to look for the Microsoft PressĀ® book Developing International Software.  I found it very helpful but was disappointed to see the far-east character tables used as filler.

Good Luck

Phillip


0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now