* East Asian locales era patch from Mantis #33003

git-svn-id: trunk@37944 -
This commit is contained in:
marco 2018-01-11 10:29:32 +00:00
parent 8aaa3c0fd5
commit af85960d62
2 changed files with 9 additions and 26 deletions

View File

@ -1079,7 +1079,7 @@ var
':': StoreStr(@FormatSettings.TimeSeparator, 1); ':': StoreStr(@FormatSettings.TimeSeparator, 1);
'[': if (fdoInterval in Options) then isInterval := true else StoreStr(FormatCurrent, 1); '[': if (fdoInterval in Options) then isInterval := true else StoreStr(FormatCurrent, 1);
']': if (fdoInterval in Options) then isInterval := false else StoreStr(FormatCurrent, 1); ']': if (fdoInterval in Options) then isInterval := false else StoreStr(FormatCurrent, 1);
' ', 'C', 'D', 'H', 'M', 'N', 'S', 'T', 'Y', 'Z', 'F' : ' ', 'C', 'D', 'H', 'M', 'N', 'S', 'T', 'Y', 'Z', 'F' {$IFDEF MSWindows}, 'G', 'E'{$ENDIF MSWindows} :
begin begin
while (P < FormatEnd) and (UpCase(P^) = Token) do while (P < FormatEnd) and (UpCase(P^) = Token) do
Inc(P); Inc(P);
@ -1183,7 +1183,7 @@ var
'E': 'E':
begin begin
if not Eastasiainited then InitEastAsia; if not Eastasiainited then InitEastAsia;
if Not(isEnable_E_Format) then StoreStr(@FormatCurrent^, 1) if Not(isEnable_E_Format) then StoreStr(FormatCurrent, 1)
else else
begin begin
while (P < FormatEnd) and (UpCase(P^) = Token) do while (P < FormatEnd) and (UpCase(P^) = Token) do
@ -1197,7 +1197,7 @@ var
'G': 'G':
begin begin
if not Eastasiainited then InitEastAsia; if not Eastasiainited then InitEastAsia;
if Not(isEnable_G_Format) then StoreStr(@FormatCurrent^, 1) if Not(isEnable_G_Format) then StoreStr(FormatCurrent, 1)
else else
begin begin
while (P < FormatEnd) and (UpCase(P^) = Token) do while (P < FormatEnd) and (UpCase(P^) = Token) do

View File

@ -744,39 +744,22 @@ end;
function ConvertEraString(Count ,Year,Month,Day : integer) : string; function ConvertEraString(Count ,Year,Month,Day : integer) : string;
var var
ASystemTime: TSystemTime; ASystemTime: TSystemTime;
buf: array[0..100] of char; wbuf: array[0..100] of WideChar;
ALCID : LCID; ALCID : LCID;
PriLangID : Word;
SubLangID : Word;
begin begin
Result := ''; if (Count<=0) then exit; Result := ''; if (Count<=0) then exit;
DateTimeToSystemTime(EncodeDate(Year,Month,Day),ASystemTime); DateTimeToSystemTime(EncodeDate(Year,Month,Day),ASystemTime);
ALCID := GetThreadLocale; ALCID := GetThreadLocale;
// ALCID := SysLocale.DefaultLCID; // ALCID := SysLocale.DefaultLCID;
if GetDateFormatA(ALCID , DATE_USE_ALT_CALENDAR if GetDateFormatW(ALCID , DATE_USE_ALT_CALENDAR
, @ASystemTime, PChar('gg') , @ASystemTime, PWChar('gg')
, @buf, SizeOf(buf)) > 0 then , @wbuf, SizeOf(wbuf)) > 0 then
begin begin
Result := buf;
if Count = 1 then if Count = 1 then
begin wbuf[1] := #0;
PriLangID := ALCID and $3FF; Result := string(WideString(wbuf));
SubLangID := (ALCID and $FFFF) shr 10;
case PriLangID of
LANG_JAPANESE:
begin
Result := Copy(WideString(Result),1,1);
end;
LANG_CHINESE:
if (SubLangID = SUBLANG_CHINESE_TRADITIONAL) then
begin
Result := Copy(WideString(Result),1,1);
end;
end;
end;
end; end;
// if Result = '' then Result := StringOfChar('G',Count);
end; end;
function ConvertEraYearString(Count ,Year,Month,Day : integer) : string; function ConvertEraYearString(Count ,Year,Month,Day : integer) : string;