mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-30 11:20:23 +02:00
* fix currency copy with extra safety on *BSD, fixed ampm
git-svn-id: trunk@10804 -
This commit is contained in:
parent
aed42d9eeb
commit
619ccffac0
@ -124,7 +124,9 @@ procedure GetFormatSettings;
|
|||||||
function TransformFormatStr(const s: string): string;
|
function TransformFormatStr(const s: string): string;
|
||||||
var
|
var
|
||||||
i, l: integer;
|
i, l: integer;
|
||||||
|
clock12:boolean;
|
||||||
begin
|
begin
|
||||||
|
clock12:=false; // should ampm get appended?
|
||||||
TransformFormatStr := '';
|
TransformFormatStr := '';
|
||||||
i := 1;
|
i := 1;
|
||||||
l := Length(s);
|
l := Length(s);
|
||||||
@ -150,16 +152,28 @@ procedure GetFormatSettings;
|
|||||||
'G': TransformFormatStr := TransformFormatStr + 'yyyy';
|
'G': TransformFormatStr := TransformFormatStr + 'yyyy';
|
||||||
'h': TransformFormatStr := TransformFormatStr + 'mmm';
|
'h': TransformFormatStr := TransformFormatStr + 'mmm';
|
||||||
'H': TransformFormatStr := TransformFormatStr + 'hh';
|
'H': TransformFormatStr := TransformFormatStr + 'hh';
|
||||||
'I': TransformFormatStr := TransformFormatStr + 'hhampm';
|
'I': begin
|
||||||
|
TransformFormatStr := TransformFormatStr + 'hh';
|
||||||
|
clock12:=true;
|
||||||
|
end;
|
||||||
//'j':
|
//'j':
|
||||||
'k': TransformFormatStr := TransformFormatStr + 'h';
|
'k': TransformFormatStr := TransformFormatStr + 'h';
|
||||||
'l': TransformFormatStr := TransformFormatStr + 'hampm';
|
'l': begin
|
||||||
|
TransformFormatStr := TransformFormatStr + 'h';
|
||||||
|
clock12:=true;
|
||||||
|
end;
|
||||||
'm': TransformFormatStr := TransformFormatStr + 'mm';
|
'm': TransformFormatStr := TransformFormatStr + 'mm';
|
||||||
'M': TransformFormatStr := TransformFormatStr + 'nn';
|
'M': TransformFormatStr := TransformFormatStr + 'nn';
|
||||||
'n': TransformFormatStr := TransformFormatStr + sLineBreak;
|
'n': TransformFormatStr := TransformFormatStr + sLineBreak;
|
||||||
'p': TransformFormatStr := TransformFormatStr + 'ampm';
|
'p','P':
|
||||||
'P': TransformFormatStr := TransformFormatStr + 'ampm';
|
begin
|
||||||
'r': TransformFormatStr := TransformFormatStr + 'hhampm:nn:ss';
|
TransformFormatStr := TransformFormatStr + 'ampm';
|
||||||
|
clock12:=false;
|
||||||
|
end;
|
||||||
|
'r': begin
|
||||||
|
TransformFormatStr := TransformFormatStr + 'hh:nn:ss';
|
||||||
|
clock12:=true;
|
||||||
|
end;
|
||||||
'R': TransformFormatStr := TransformFormatStr + 'hh:nn';
|
'R': TransformFormatStr := TransformFormatStr + 'hh:nn';
|
||||||
//'s':
|
//'s':
|
||||||
'S': TransformFormatStr := TransformFormatStr + 'ss';
|
'S': TransformFormatStr := TransformFormatStr + 'ss';
|
||||||
@ -182,6 +196,13 @@ procedure GetFormatSettings;
|
|||||||
TransformFormatStr := TransformFormatStr + s[i];
|
TransformFormatStr := TransformFormatStr + s[i];
|
||||||
inc(i);
|
inc(i);
|
||||||
end;
|
end;
|
||||||
|
i:=length(TransformFormatStr);
|
||||||
|
if clock12 and (i>0) then
|
||||||
|
begin
|
||||||
|
if transformformatstr[i]<>' ' then
|
||||||
|
TransformFormatStr := TransformFormatStr + ' ';
|
||||||
|
TransformFormatStr := TransformFormatStr + 'ampm';
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
const
|
const
|
||||||
@ -245,8 +266,10 @@ begin
|
|||||||
plocale:=localeconv;
|
plocale:=localeconv;
|
||||||
// for these fields there is a separate BSD derived POSIX function.
|
// for these fields there is a separate BSD derived POSIX function.
|
||||||
if not assigned(plocale) then exit; // for now.
|
if not assigned(plocale) then exit; // for now.
|
||||||
CurrencyString:=plocale^.CURRENCY_SYMBOL;
|
|
||||||
CurrencyString := Copy(CurrencyString, 1, Length(CurrencyString));
|
CurrencyString:=plocale^.currency_symbol; // int_CURR_SYMBOL (in latin chars)
|
||||||
|
if CurrencyString='' then
|
||||||
|
CurrencyString:=plocale^.int_curr_symbol;
|
||||||
CurrencyDecimals:=ord(plocale^.FRAC_DIGITS);
|
CurrencyDecimals:=ord(plocale^.FRAC_DIGITS);
|
||||||
{$ifdef localedebug}
|
{$ifdef localedebug}
|
||||||
OrgFormatSettings.CurrencyString1:=plocale^.currency_symbol;
|
OrgFormatSettings.CurrencyString1:=plocale^.currency_symbol;
|
||||||
|
Loading…
Reference in New Issue
Block a user