Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to Check Language in VFP app.
Message
De
11/09/2003 06:41:57
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00726646
Message ID:
00828088
Vues:
16
Excellent. Complete, comprehensive and it works.

Would like to award maximum marks but made the mistake of starting my query in someone else's thread. Sorry but Thanks!

>Harry,

>
>If commands SET SYSFORMATS ON and SET DATE TO SHORT (LONG) cannot help you, then regional date constants are given in the example below:
>
>#define LOCALE_USER_DEFAULT           BitLShift(0x01, 10)    && user default
>#define LOCALE_SYSTEM_DEFAULT         BitLShift(0x02, 10)    && system default
>
>#define LOCALE_SDATE                  0x0000001D   && date separator
>#define LOCALE_STIME                  0x0000001E   && time separator
>#define LOCALE_SSHORTDATE             0x0000001F   && short date format string
>#define LOCALE_SLONGDATE              0x00000020   && long date format string
>#define LOCALE_STIMEFORMAT            0x00001003   && time format string
>#define LOCALE_IDATE                  0x00000021   && short date format ordering
>#define LOCALE_ILDATE                 0x00000022   && long date format ordering
>#define LOCALE_ITIME                  0x00000023   && time format specifier
>#define LOCALE_ITIMEMARKPOSN          0x00001005   && time marker position
>#define LOCALE_ICENTURY               0x00000024   && century format specifier (short date)
>#define LOCALE_ITLZERO                0x00000025   && leading zeros in time field
>#define LOCALE_IDAYLZERO              0x00000026   && leading zeros in day field (short date)
>#define LOCALE_IMONLZERO              0x00000027   && leading zeros in month field (short date)
>#define LOCALE_S1159                  0x00000028   && AM designator
>#define LOCALE_S2359                  0x00000029   && PM designator
>
>Declare Integer GetLocaleInfo in Win32API ;
>    Long Locale, Long LCType, String @ LCData, Integer size
>Buff = Space(256)
>
>* Short date format ordering (0 - MDY, 1 - DMY, 2 - YMD)
>len = GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_IDATE, @Buff, 256)
>? Left(Buff, len-1)
>
>* Date separator
>len = GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SDATE, @Buff, 256)
>? Left(Buff, len-1)
>
>* Century format (0 - 2-digit, 1 - 4-digit)
>len = GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_ICENTURY, @Buff, 256)
>? Left(Buff, len-1)
>
>To retrieve local month and weekday names you can use the following functions (two versions for each - using GetLocaleInfo() and VarMonthName()/VarWeekdayName()):
>
>Function LocalMonthName1(tnMonth, tlAbbrev)
>If (VarType(tnMonth) != 'N') Or (tnMonth < 1) Or (tnMonth > 12) Or (VarType(tlAbbrev) != 'L')
>	Error 11
>EndIf
>
>Local buf, n
>Declare Long GetLocaleInfo In Win32API ;
>	Long Locale, Long LCType, String @ lpLCData, Long cchData
>buf = Replicate(Chr(0), 16)
>n = GetLocaleInfo(0, IIf(tlAbbrev, 0x43, 0x37) + tnMonth, @buf, 16)
>Return Left(buf, n - 1)
>
>
>Function LocalMonthName2(tnMonth, tlAbbrev)
>If (VarType(tnMonth) != 'N') Or (tnMonth < 1) Or (tnMonth > 12) Or (VarType(tlAbbrev) != 'L')
>	Error 11
>EndIf
>
>Local bstr, buf, n
>Declare Long VarMonthName In Oleaut32.dll ;
>	Long iMonth, Long fAbbrev, Long dwFlags, Long @ pbstrOut
>Declare Long WideCharToMultiByte In Win32API ;
>	Long CodePage, Long dwFlags, Long lpWideStr, Long cchWide, ;
>	String @ lpMultiByte, Long cbMultiByte, Long lpDefaultChar, Long lpUsedDefaultChar
>Declare Long SysStringLen In Oleaut32.dll Long bstr
>Declare SysFreeString In Oleaut32.dll Long bstr
>bstr = 0
>VarMonthName(tnMonth, Iif(tlAbbrev, 1, 0), 0, @bstr)
>buf = Replicate(Chr(0), 16)
>n = WideCharToMultiByte(0, 0, bstr, SysStringLen(bstr), @buf, 16, 0, 0)
>SysFreeString(bstr)
>Return Left(buf, n)
>
>
>Function LocalWeekdayName1(tnWeekday, tlAbbrev)
>If (VarType(tnWeekday) != 'N') Or (tnWeekday < 1) Or (tnWeekday > 7) Or (VarType(tlAbbrev) != 'L')
>	Error 11
>EndIf
>
>Local buf, n
>Declare Long GetLocaleInfo In Win32API ;
>	Long Locale, Long LCType, String @ lpLCData, Long cchData
>buf = Replicate(Chr(0), 16)
>n = GetLocaleInfo(0, IIf(tlAbbrev, 0x30, 0x29) + tnWeekday, @buf, 16)
>Return Left(buf, n - 1)
>
>
>Function LocalWeekdayName2(tnWeekday, tlAbbrev)
>If (VarType(tnWeekday) != 'N') Or (tnWeekday < 1) Or (tnWeekday > 7) Or (VarType(tlAbbrev) != 'L')
>	Error 11
>EndIf
>
>Local bstr, buf, n
>Declare Long VarWeekdayName In Oleaut32.dll ;
>	Long iWeekday, Long fAbbrev, Long iFirstDay, Long dwFlags, Long @ pbstrOut
>Declare Long WideCharToMultiByte In Win32API ;
>	Long CodePage, Long dwFlags, Long lpWideStr, Long cchWide, ;
>	String @ lpMultiByte, Long cbMultiByte, Long lpDefaultChar, Long lpUsedDefaultChar
>Declare Long SysStringLen In Oleaut32.dll Long bstr
>Declare SysFreeString In Oleaut32.dll Long bstr
>bstr = 0
>VarWeekdayName(tnWeekday, Iif(tlAbbrev, 1, 0), 0, 0, @bstr)
>buf = Replicate(Chr(0), 16)
>n = WideCharToMultiByte(0, 0, bstr, SysStringLen(bstr), @buf, 16, 0, 0)
>SysFreeString(bstr)
>Return Left(buf, n)
>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform