mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-11 13:45:58 +02:00
* fixed compatibility problem of DateTimeToString
This commit is contained in:
parent
89d569f6f9
commit
36efa2d7b5
@ -551,7 +551,7 @@ var
|
|||||||
|
|
||||||
procedure StoreFormat(const FormatStr: string);
|
procedure StoreFormat(const FormatStr: string);
|
||||||
var
|
var
|
||||||
Token: char;
|
Token,lastformattoken: char;
|
||||||
FormatCurrent: pchar;
|
FormatCurrent: pchar;
|
||||||
FormatEnd: pchar;
|
FormatEnd: pchar;
|
||||||
Count: integer;
|
Count: integer;
|
||||||
@ -581,7 +581,9 @@ var
|
|||||||
end ;
|
end ;
|
||||||
P := P + 1;
|
P := P + 1;
|
||||||
end ;
|
end ;
|
||||||
while FormatCurrent < FormatEnd do begin
|
token:=#255;
|
||||||
|
while FormatCurrent < FormatEnd do
|
||||||
|
begin
|
||||||
Token := UpCase(FormatCurrent^);
|
Token := UpCase(FormatCurrent^);
|
||||||
Count := 1;
|
Count := 1;
|
||||||
P := FormatCurrent + 1;
|
P := FormatCurrent + 1;
|
||||||
@ -614,76 +616,88 @@ var
|
|||||||
end ;
|
end ;
|
||||||
'/': StoreStr(@DateSeparator, 1);
|
'/': StoreStr(@DateSeparator, 1);
|
||||||
':': StoreStr(@TimeSeparator, 1);
|
':': StoreStr(@TimeSeparator, 1);
|
||||||
' ', 'C', 'D', 'H', 'M', 'N', 'S', 'T', 'Y','Z' : begin
|
' ', 'C', 'D', 'H', 'M', 'N', 'S', 'T', 'Y','Z' :
|
||||||
while (P < FormatEnd) and (UpCase(P^) = Token) do
|
begin
|
||||||
|
while (P < FormatEnd) and (UpCase(P^) = Token) do
|
||||||
P := P + 1;
|
P := P + 1;
|
||||||
Count := P - FormatCurrent;
|
Count := P - FormatCurrent;
|
||||||
case Token of
|
case Token of
|
||||||
' ': StoreStr(FormatCurrent, Count);
|
' ': StoreStr(FormatCurrent, Count);
|
||||||
'Y': begin
|
'Y': begin
|
||||||
case Count of
|
if Count>2 then
|
||||||
1: StoreInt(Year, 0);
|
StoreInt(Year, 4)
|
||||||
2: StoreInt(Year mod 100, 2);
|
else
|
||||||
4: StoreInt(Year, 4);
|
StoreInt(Year mod 100, 2);
|
||||||
end ;
|
end;
|
||||||
end ;
|
'M': begin
|
||||||
'M': begin
|
if lastformattoken='H' then
|
||||||
case Count of
|
begin
|
||||||
1: StoreInt(Month, 0);
|
if Count = 1 then
|
||||||
2: StoreInt(Month, 2);
|
StoreInt(Minute, 0)
|
||||||
3: StoreString(ShortMonthNames[Month]);
|
else
|
||||||
4: StoreString(LongMonthNames[Month]);
|
StoreInt(Minute, 2);
|
||||||
end ;
|
|
||||||
end ;
|
|
||||||
'D': begin
|
|
||||||
case Count of
|
|
||||||
1: StoreInt(Day, 0);
|
|
||||||
2: StoreInt(Day, 2);
|
|
||||||
3: StoreString(ShortDayNames[DayOfWeek]);
|
|
||||||
4: StoreString(LongDayNames[DayOfWeek]);
|
|
||||||
5: StoreFormat(ShortDateFormat);
|
|
||||||
6: StoreFormat(LongDateFormat);
|
|
||||||
end ;
|
|
||||||
end ;
|
|
||||||
'H': begin
|
|
||||||
if Clock12 then begin
|
|
||||||
tmp:=hour mod 12;
|
|
||||||
if tmp=0 then tmp:=12;
|
|
||||||
if Count = 1 then StoreInt(tmp, 0)
|
|
||||||
else StoreInt(tmp, 2);
|
|
||||||
end
|
end
|
||||||
else begin
|
else
|
||||||
if Count = 1 then StoreInt(Hour, 0)
|
begin
|
||||||
else StoreInt(Hour, 2);
|
case Count of
|
||||||
end ;
|
1: StoreInt(Month, 0);
|
||||||
end ;
|
2: StoreInt(Month, 2);
|
||||||
'N': begin
|
3: StoreString(ShortMonthNames[Month]);
|
||||||
if Count = 1 then StoreInt(Minute, 0)
|
4: StoreString(LongMonthNames[Month]);
|
||||||
else StoreInt(Minute, 2);
|
end;
|
||||||
end ;
|
end;
|
||||||
'S': begin
|
end;
|
||||||
if Count = 1 then StoreInt(Second, 0)
|
'D': begin
|
||||||
else StoreInt(Second, 2);
|
case Count of
|
||||||
end ;
|
1: StoreInt(Day, 0);
|
||||||
'Z': begin
|
2: StoreInt(Day, 2);
|
||||||
if Count = 1 then StoreInt(MilliSecond, 0)
|
3: StoreString(ShortDayNames[DayOfWeek]);
|
||||||
else StoreInt(MilliSecond, 3);
|
4: StoreString(LongDayNames[DayOfWeek]);
|
||||||
end ;
|
5: StoreFormat(ShortDateFormat);
|
||||||
'T': begin
|
6: StoreFormat(LongDateFormat);
|
||||||
if Count = 1 then StoreFormat(timereformat(ShortTimeFormat))
|
end ;
|
||||||
else StoreFormat(TimeReformat(LongTimeFormat));
|
end ;
|
||||||
end ;
|
'H': begin
|
||||||
'C':
|
if Clock12 then begin
|
||||||
begin
|
tmp:=hour mod 12;
|
||||||
StoreFormat(ShortDateFormat);
|
if tmp=0 then tmp:=12;
|
||||||
if (Hour<>0) or (Minute<>0) or (Second<>0) then
|
if Count = 1 then StoreInt(tmp, 0)
|
||||||
begin
|
else StoreInt(tmp, 2);
|
||||||
StoreString(' ');
|
end
|
||||||
StoreFormat(TimeReformat(ShortTimeFormat));
|
else begin
|
||||||
end;
|
if Count = 1 then StoreInt(Hour, 0)
|
||||||
end;
|
else StoreInt(Hour, 2);
|
||||||
end ;
|
end ;
|
||||||
end ;
|
end ;
|
||||||
|
'N': begin
|
||||||
|
if Count = 1 then StoreInt(Minute, 0)
|
||||||
|
else StoreInt(Minute, 2);
|
||||||
|
end ;
|
||||||
|
'S': begin
|
||||||
|
if Count = 1 then StoreInt(Second, 0)
|
||||||
|
else StoreInt(Second, 2);
|
||||||
|
end ;
|
||||||
|
'Z': begin
|
||||||
|
if Count = 1 then StoreInt(MilliSecond, 0)
|
||||||
|
else StoreInt(MilliSecond, 3);
|
||||||
|
end ;
|
||||||
|
'T': begin
|
||||||
|
if Count = 1 then StoreFormat(timereformat(ShortTimeFormat))
|
||||||
|
else StoreFormat(TimeReformat(LongTimeFormat));
|
||||||
|
end ;
|
||||||
|
'C':
|
||||||
|
begin
|
||||||
|
StoreFormat(ShortDateFormat);
|
||||||
|
if (Hour<>0) or (Minute<>0) or (Second<>0) then
|
||||||
|
begin
|
||||||
|
StoreString(' ');
|
||||||
|
StoreFormat(TimeReformat(ShortTimeFormat));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
lastformattoken:=token;
|
||||||
|
end;
|
||||||
else
|
else
|
||||||
StoreStr(@Token, 1);
|
StoreStr(@Token, 1);
|
||||||
end ;
|
end ;
|
||||||
@ -740,7 +754,10 @@ end;
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.6 2005-02-14 17:13:31 peter
|
Revision 1.7 2005-03-10 19:48:27 florian
|
||||||
|
* fixed compatibility problem of DateTimeToString
|
||||||
|
|
||||||
|
Revision 1.6 2005/02/14 17:13:31 peter
|
||||||
* truncate log
|
* truncate log
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user