[fpc-pascal] Re: DateTime bug

Richard Jasmin jasminr at lavabit.com
Wed Jul 15 18:59:55 CEST 2009


Its off by about 8 hrs on unix and the date, um...I get a single digit
from the CMOS or whereever for the year.I have to fudge the numbers a
little.
Confirmed. Time  zone differences are NOT taken into account with FPC
for some reason.Instead you get a standard date/time.

It took me a little while to figure out.Mine are off by 8 between Ubuntu
and real-mode boot.Real-mode being the more accurate of the two.

fpc-pascal-request at lists.freepascal.org wrote:
> Send fpc-pascal mailing list submissions to
> 	fpc-pascal at lists.freepascal.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://lists.freepascal.org/mailman/listinfo/fpc-pascal
> or, via email, send a message with subject or body 'help' to
> 	fpc-pascal-request at lists.freepascal.org
>
> You can reach the person managing the list at
> 	fpc-pascal-owner at lists.freepascal.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of fpc-pascal digest..."
>
>
> Today's Topics:
>
>    1. Re:  How to use FCGI? (Joost van der Sluis)
>    2.  DateTimeToUnix bug ? (Koenraad Lelong)
>    3. Re:  DateTimeToUnix bug ? (Jonas Maebe)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 15 Jul 2009 11:01:29 +0200
> From: Joost van der Sluis <joost at cnoc.nl>
> Subject: Re: [fpc-pascal] How to use FCGI?
> To: FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
> Message-ID: <1247648489.7472.3.camel at wsjoost>
> Content-Type: text/plain; charset=UTF-8
>
> Op maandag 13-07-2009 om 11:07 uur [tijdzone +0200], schreef Artur
> Stuczyński:
>   
>> OK, thanks, got it working.
>>
>> Please correct me, if I am wrong, but this approach makes developing and debugging harder, because it is httpd which spawns the application, so to effectively kill the app and replace it with new build I have to restart the httpd (at least with lighttpd which I tested).
>>
>> I see possible resulutions:
>>
>> 1. Create the application as a standard CGI and convert it to FCGI on deployment
>> or
>> 2. Make TCustomFCGIApplication's descendant and replace WaitForRequest with own code which binds, listens and accepts connections from httpd. Then, upon compilation, I need only to restart my application.
>>
>> Am I right?
>>     
>
> Easiest is to use the embedded-web-server I've send to this list a month
> ago. That way you can debug from within the Lazarus-ide. When you deploy
> your application, you can compile as FastCGI. (Switch one unit in your
> uses-clausule and you're done)
>
> Joost.
>
>
>
> ------------------------------
>
> Message: 2
> Date: Wed, 15 Jul 2009 11:06:39 +0200
> From: Koenraad Lelong <fpascal at brouwerij.homelinux.net>
> Subject: [fpc-pascal] DateTimeToUnix bug ?
> To: fpc-pascal at lists.freepascal.org
> Message-ID: <4A5D9C1F.9010808 at brouwerij.homelinux.net>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Hi,
> I have a linux application where I use DatetimeToUnix. I think it 
> contains a bug.
> Every minute I put a sample in an rrddb (rrdtool). When I dump the 
> rrddb, the time of the samples is 2 hours in the future. Those 2 hours 
> happen to be the time-zone difference, between UTC and CEST.
> Anyone can verify this ?
>
> This is what I used to test this :
> program DateTest;
> {$ifdef FPC}{$mode objfpc}{$h+}{$INTERFACES CORBA}{$endif}
> {$ifdef mswindows}{$apptype console}{$endif}
> uses
>   {$ifdef FPC}{$ifdef linux}cthreads,{$endif}{$endif}
>   sysutils, dateutils;
>
> var
>   Nu : TDateTime;
>
> begin
>
> Nu:=Now;
> writeln(nu:1:8,' ',DateTimeToStr(nu),' ',DatetimeToUnix(Nu));
> end.
>
> When I run "./DateTest && date +%s && date" I get :
> 40009.44713685 15-7-09 10:43:52 1247654632
> 1247647432
> wo jul 15 10:43:52 CEST 2009
>
> Between the fpc-version and the linux-version of the unix-time there is 
> 7200 seconds difference, fpc running ahead.
>
> Is it a bug, or am I missing someting ? This happens with FPC 2.4.
>
> Regards,
> Koenraad Lelong.
>
>
> ------------------------------
>
> Message: 3
> Date: Wed, 15 Jul 2009 11:43:53 +0200
> From: Jonas Maebe <jonas.maebe at elis.ugent.be>
> Subject: Re: [fpc-pascal] DateTimeToUnix bug ?
> To: FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
> Message-ID: <7BD3638F-7142-47E1-A6FF-44FFB5A60382 at elis.ugent.be>
> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
>
>
> On 15 Jul 2009, at 11:06, Koenraad Lelong wrote:
>
>   
>> I have a linux application where I use DatetimeToUnix. I think it  
>> contains a bug.
>> Every minute I put a sample in an rrddb (rrdtool). When I dump the  
>> rrddb, the time of the samples is 2 hours in the future. Those 2  
>> hours happen to be the time-zone difference, between UTC and CEST.
>>     
>
> DatetimeToUnix is defined as returning the "Unix epoch time  
> corresponding to AValue". So by definition it does not perform any  
> time zone adjustments (which is logical, since there is no information  
> regarding what time zone the input value is related to). It's the same  
> in Delphi (just google for DatetimeToUnix+timezone
>
> If you want "now" using the local time zone, use sysutils.getlocaltime  
> instead.
>
>
> Jonas
>
>
> ------------------------------
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
> End of fpc-pascal Digest, Vol 61, Issue 16
> ******************************************
>
> ____________________________________________________________________________________
> Use the link below to report this message as spam.
> https://lavabit.com/apps/teacher?sig=651145&key=3466455751
> ____________________________________________________________________________________
>
>   

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 249 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20090715/fbd68296/attachment.sig>


More information about the fpc-pascal mailing list