Function GetMonthNum(Month: String): Word;
Var I : Integer;
PMonth, PShortMonth, PLongMonth : PChar;
Begin
Result := 0;
PMonth := PChar(Month);
For I := 1 To 12 Do Begin
PShortMonth := PChar(ShortMonthNames[I]);
PLongMonth := PChar(LongMonthNames[I]);
If (CompareString(LOCALE_USER_DEFAULT, SORT_STRINGSORT Or NORM_IGNORECASE
Or NORM_IGNORENONSPACE Or NORM_IGNORESYMBOLS, PMonth, -1, PShortMonth,
-1) = CSTR_EQUAL) Or (CompareString(LOCALE_USER_DEFAULT, SORT_STRINGSORT
Or NORM_IGNORECASE Or NORM_IGNORENONSPACE Or NORM_IGNORESYMBOLS, PMonth,
-1, PLongMonth, -1) = CSTR_EQUAL) Then
Begin
Result := I;
Break;
End;
End;
End;
Remarque :
Cette fonction accèpte toutes les langues
la comparaison ne tiens pas compte des accents ni des caractères spéciaux
ni de la case.
"Déc", "dec", "dèc", "Dec.", "[Dec.]", "[ Dec. ]" -------->> donne 12
"Aout", "aôut", "août", "aout", "[Aout]", "[ Aout ]" ----->> donne 8