Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2008-02

Local Time

8 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Carsten Bager

My problem is that I get UTC time with the 220 compiler on the Arm platform, when using gettime, now ---.
If i compile my program "lt" (local time) with the 220 compiler on Linux 386 it works as I expects.
If I compile it to an Arm Linux it fails but if I use the 204 compiler it works. I have to use the 220 compiler on my project. Is there a way around this problem.

Regards
Carsten

Output from 220 compiler on 386 Linux
LTC:21/02-2008 8:59:20:416
UTC:21/02-2008 7:59:20:00

Output from 220 compiler on Arm Linux
Thu Feb 21 08:02:35 UTC 2008
LTC:21/02-2008 8:02:25:656
UTC:21/02-2008 8:03:45:00

Output from 204 compiler on Arm Linux
LTC:21/02-2008 8:50:48:421
UTC:21/02-2008 7:50:48:00

-------------------------------------------------------------------------------------------- {Datotid test program}

{$mode objfpc}
{$LONGSTRINGS OFF}
{$IFDEF DEBUG}                  {Compileren kan leverer denne definition}
  {$RANGECHECKS ON}
  { $OVERFLOWCHECKS ON}         {Der er problemer med denne paa
ARM 9}
  {$S+ STACK CHECKING ON}
  {$SMARTLINK ON}
  {$TYPEINFO ON}
  {$DEFINE DEBUGCALNANOX}
{$ENDIF}

Program lt;
Uses unix,
Swrite,
baseunix,
sysutils; {System}

Var
  SystemTime:TSystemTime;
  DateTime:TDateTime;
Procedure GetUtcTime(var SystemTime: TSystemTime);
Var
  DateTime:TDateTime;
Begin
  DateTime:=(fptime / 86400.0) + 25569;
  DateTimeToSystemTime(DateTime,SystemTime);
End;
Function SystemTimeToStr(dt:TSystemTime):shortstring;
Begin
  SystemTimeToStr:=intToStrR(dt.Day,2)+'/'+
                   intToStr0(dt.Month,2)+'-'+
                   intToStr0(dt.Year,4)+
                   intToStrR(dt.Hour,3)+':'+
                   intToStr0(dt.Minute,2)+':'+
                   intToStr0(dt.Second,2)+':'+
                   intToStr0(dt.MilliSecond,2);
End;
Begin
  GetLocalTime(SystemTime);
  WriteLn('LTC:',SystemTimeToStr(SystemTime));
  GetUtcTime(SystemTime);
  WriteLn('UTC:',SystemTimeToStr(SystemTime));
End.
Med venlig hilsen
Carsten Bager

BEAS A/S
Brørupvænget 10
DK-7650 Bøvlingbjerg
Tlf. : +45 9788 5222 Fax : +45 9788 5434
www.beas.dk

Florian Klaempfl
to Carsten Bager
Show quoted text 7 lines
My problem is that I get UTC time with the 220 compiler on the Arm platform, when using gettime, now ---. If i compile my program "lt" (local time) with the 220 compiler on Linux 386 it works as I expects. If I compile it to an Arm Linux it fails but if I use the 204 compiler it works. I have to use the 220 compiler on my project. Is there a way around this problem.

Can you post straces?

Show quoted text 93 lines
Regards Carsten Output from 220 compiler on 386 Linux LTC:21/02-2008 8:59:20:416 UTC:21/02-2008 7:59:20:00 Output from 220 compiler on Arm Linux Thu Feb 21 08:02:35 UTC 2008 LTC:21/02-2008 8:02:25:656 UTC:21/02-2008 8:03:45:00 Output from 204 compiler on Arm Linux LTC:21/02-2008 8:50:48:421 UTC:21/02-2008 7:50:48:00 -------------------------------------------------------------------------------------------- {Datotid test program} {$mode objfpc} {$LONGSTRINGS OFF} {$IFDEF DEBUG} {Compileren kan leverer denne definition} {$RANGECHECKS ON} { $OVERFLOWCHECKS ON} {Der er problemer med denne paa ARM 9} {$S+ STACK CHECKING ON} {$SMARTLINK ON} {$TYPEINFO ON} {$DEFINE DEBUGCALNANOX} {$ENDIF} Program lt; Uses unix, Swrite, baseunix, sysutils; {System} Var SystemTime:TSystemTime; DateTime:TDateTime; Procedure GetUtcTime(var SystemTime: TSystemTime); Var DateTime:TDateTime; Begin DateTime:=(fptime / 86400.0) + 25569; DateTimeToSystemTime(DateTime,SystemTime); End; Function SystemTimeToStr(dt:TSystemTime):shortstring; Begin SystemTimeToStr:=intToStrR(dt.Day,2)+'/'+ intToStr0(dt.Month,2)+'-'+ intToStr0(dt.Year,4)+ intToStrR(dt.Hour,3)+':'+ intToStr0(dt.Minute,2)+':'+ intToStr0(dt.Second,2)+':'+ intToStr0(dt.MilliSecond,2); End; Begin GetLocalTime(SystemTime); WriteLn('LTC:',SystemTimeToStr(SystemTime)); GetUtcTime(SystemTime); WriteLn('UTC:',SystemTimeToStr(SystemTime)); End. Med venlig hilsen Carsten Bager BEAS A/S Brørupvænget 10 DK-7650 Bøvlingbjerg Tlf. : +45 9788 5222 Fax : +45 9788 5434 www.beas.dk _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Carsten Bager
to Florian Klaempfl
Can you post straces?

I can not run strace on my Arm9 platform. Is there another way.

CarstenMed venlig hilsen
Carsten Bager

BEAS A/S
Brørupvænget 10
DK-7650 Bøvlingbjerg
Tlf. : +45 9788 5222 Fax : +45 9788 5434
www.beas.dk

Jonas Maebe
to Carsten Bager: My problem is that I get UTC time with the 220 compiler on the Arm platform, when using…
Carsten Bager wrote 7 lines
My problem is that I get UTC time with the 220 compiler on the Arm platform, when using gettime, now ---. If i compile my program "lt" (local time) with the 220 compiler on Linux 386 it works as I expects. If I compile it to an Arm Linux it fails but if I use the 204 compiler it works.

Under Linux, FPC tries to read the timezone info from (in this order)

/etc/timezone
/etc/localtime
/usr/lib/zoneinfo/localtime

I guess the Linux on your Arm device stores it in yet another place (or one of these files exist but does not contain the correct time zone info).

Jonas

Carsten Bager
to Jonas Maebe
Show quoted text 20 lines
On 21 Feb 2008, at 09:15, Carsten Bager wrote: > My problem is that I get UTC time with the 220 compiler on the Arm > platform, when using gettime, now ---. > If i compile my program "lt" (local time) with the 220 compiler on > Linux 386 > it works as I expects. > If I compile it to an Arm Linux it fails but if I use the 204 > compiler it works. Under Linux, FPC tries to read the timezone info from (in this order) /etc/timezone /etc/localtime /usr/lib/zoneinfo/localtime I guess the Linux on your Arm device stores it in yet another place (or one of these files exist but does not contain the correct time zone info).

As I wrote in my first mail. The same program compiled with the 204 compiler works on the same Arm 9 platform.
So the program compiled with the 204 compiler finds the "/etc/localtime" file and reads it.

Carsten

Carsten Bager
to Carsten Bager

I tried the 221 compiler. The error I reported is gone here, but there still is something fishy about it.
When running the 204 program my UTC time is always updated with the correct time. But when running the 221 program the time can be behind by several minutes.
I then rewrote my GetUtcTime procedure to:

Procedure GetUtcTime(var SystemTime: TSystemTime);
Var
  DateTime:TDateTime;
  fptimeS:TDateTime;
Begin
  fptimeS:=fptime;
  DateTime:=(fptimeS / 86400.0) + 25569.0;
  DateTimeToSystemTime(DateTime,SystemTime);
End;

From

Procedure GetUtcTime(var SystemTime: TSystemTime);
Var
  DateTime:TDateTime;
Begin
  DateTime:=(fptime / 86400.0) + 25569;
  DateTimeToSystemTime(DateTime,SystemTime);
End;

Now it works

I would not expect to run in to trouble mixing real and integers when having real on both the right and left side. What do you say.

Regards Carsten

204 compiler on Arm 9
LTC:21/02-2008 13:53:17:944
UTC:21/02-2008 12:53:17:00

221 compiler on Arm 9
LTC:21/02-2008 13:54:41:925
UTC:21/02-2008 12:56:15:00
Med venlig hilsen
Carsten Bager

BEAS A/S
Brørupvænget 10
DK-7650 Bøvlingbjerg
Tlf. : +45 9788 5222 Fax : +45 9788 5434
www.beas.dk

Carsten Bager
to Carsten Bager: As I wrote in my first mail. The same program compiled with the 204 compiler works on the…

I tried the 221 compiler. The error I reported is gone here, but there still is something fishy about it.
When running the 204 program my UTC time is always updated with the correct time. But when running the 221 program the time can be behind by several minutes.
I then rewrote my GetUtcTime procedure to:

Procedure GetUtcTime(var SystemTime: TSystemTime);
Var
  DateTime:TDateTime;
  fptimeS:TDateTime;
Begin
  fptimeS:=fptime;
  DateTime:=(fptimeS / 86400.0) + 25569.0;
  DateTimeToSystemTime(DateTime,SystemTime);
End;

From

Procedure GetUtcTime(var SystemTime: TSystemTime);
Var
  DateTime:TDateTime;
Begin
  DateTime:=(fptime / 86400.0) + 25569;
  DateTimeToSystemTime(DateTime,SystemTime);
End;

Now it works

I would not expect to run in to trouble mixing real and integers when having real on both the right and left side. What do you say.

Regards Carsten

204 compiler on Arm 9
LTC:21/02-2008 13:53:17:944
UTC:21/02-2008 12:53:17:00

221 compiler on Arm 9
LTC:21/02-2008 13:54:41:925
UTC:21/02-2008 12:56:15:00
Med venlig hilsen
Carsten Bager

BEAS A/S
Brørupvænget 10
DK-7650 Bøvlingbjerg
Tlf. : +45 9788 5222 Fax : +45 9788 5434
www.beas.dk