DateTimeToUnix bug ?

classic Classic list List threaded Threaded
64 messages Options
1234
Reply | Threaded
Open this post in threaded view
|

DateTimeToUnix bug ?

Koenraad Lelong-2
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.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: DateTimeToUnix bug ?

Jonas Maebe-2

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  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: DateTimeToUnix bug ?

Koenraad Lelong-2
Jonas Maebe schreef:

>
> 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

Thanks Jonas, but that gives the same result. I found that
fpGetTimeOfDay does the trick.

Regards,
Koenraad.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Lazarus settings and roaming profiles in Windows

Jürgen Hestermann
I am not sure whether there exists a separate mailing list just for
Lazarus so I am posting this here:

I have seen a small discussion on
http://www.mail-archive.com/lazarus@.../msg20274.html about
where Lazarus stores its configuration settings. I wanted to mention
that I have a problem with this because on our machines at work we have
a roaming profile which only saves parts of the user profile but not the
"Local settings" branch (where Lazarus stores its settings). So after
each reboot all settings are gone. Is there a way to configure Lazarus
to use a different (non-user) path? I didn't find any option to do that.

Jürgen Hestermann.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Lazarus settings and roaming profiles in Windows

Gabor Boros
Hi,

I don't know the answer for your question but I know a separate Lazarus
mailing list exist.
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Gabor

Jürgen Hestermann írta:
> I am not sure whether there exists a separate mailing list just for
> Lazarus so I am posting this here:
>
> Jürgen Hestermann.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Persistent blocks in Lazarus

Jürgen Hestermann
In reply to this post by Koenraad Lelong-2
A question:

Do persistent blocks exist the Lazarus editor?
I didn't find any such option.
I am bit astonished about that because all Pascal forefathers like Turbo
Pascal, Virtual Pascal and Delphi had it.

If it does not exist, is it planned to add?
I miss this mode very much. It allowed a way of working which cannot be
achieved with the current temporary block mode.

Thanks in advance for answers.

Jürgen Hestermann.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Lazarus settings and roaming profiles in Windows

zaher dirkey
In reply to this post by Gabor Boros
use
c:\lazarus\Lazarus.exe --pcp=x:\lazarus\config

--
Zaher Dirkey
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Lazarus settings and roaming profiles in Windows

Jürgen Hestermann
 > Zaher Dirkey schrieb:
> use c:\lazarus\Lazarus.exe --pcp=x:\lazarus\config

Thanks for the solution!

Still I am wondering why the directory "Local Settings" is used and not
"Application Data" as all other applications do. Then it would be saved
with roaming profiles too.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Persistent blocks in Lazarus

Martin Friebe
In reply to this post by Jürgen Hestermann
First of all, Lazarus has it's own mailing list, where you will be more
likely to receive answers...

Jürgen Hestermann wrote:
> A question:
>
> Do persistent blocks exist the Lazarus editor?
Not at current.

> If it does not exist, is it planned to add?
Maybe some day. There is no concrete plan that I know of, so it isn't
likely to be any time soon.
Patches are welcome.

> I miss this mode very much. It allowed a way of working which cannot
> be achieved with the current temporary block mode.
>
Out of curiosity (because I never used this feature in any editor), what
would you use it for?

Best Regards
Martin
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Lazarus settings and roaming profiles in Windows

Luca Olivetti-2
In reply to this post by Jürgen Hestermann
En/na Jürgen Hestermann ha escrit:
>  > Zaher Dirkey schrieb:
>> use c:\lazarus\Lazarus.exe --pcp=x:\lazarus\config
>
> Thanks for the solution!
>
> Still I am wondering why the directory "Local Settings" is used and not
> "Application Data" as all other applications do. Then it would be saved
> with roaming profiles too.

http://bugs.freepascal.org/view.php?id=13908

Bye
--
Luca
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Lazarus settings and roaming profiles in Windows

Jürgen Hestermann
>> Still I am wondering why the directory "Local Settings" is used and
>> not "Application Data" as all other applications do. Then it would be
>> saved with roaming profiles too.
> Luca Olivetti schrieb:
> http://bugs.freepascal.org/view.php?id=13908

Interesting that noone mentioned the impact on roamed profiles. That's
definitely a drawback because you lose all your settings then!

Jürgen.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Lazarus settings and roaming profiles in Windows

Vincent Snijders-2
Jürgen Hestermann schreef:
>>> Still I am wondering why the directory "Local Settings" is used and
>>> not "Application Data" as all other applications do. Then it would be
>>> saved with roaming profiles too.
>> Luca Olivetti schrieb:
>> http://bugs.freepascal.org/view.php?id=13908
>
> Interesting that noone mentioned the impact on roamed profiles. That's
> definitely a drawback because you lose all your settings then!

I am not sure having a 100 MB lazarus *roaming* profile by default would
be a good idea.

Vincent
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Persistent blocks in Lazarus

Jürgen Hestermann
In reply to this post by Martin Friebe


 > Martin Friebe schrieb:
> Out of curiosity (because I never used this feature in any editor), what
> would you use it for?

I used it since Turbo Pascal 5 and found it in all other Pascal IDE's
(even in the text mode IDE of Free Pascal!). And it seems others would
like it too (see
http://www.lazarus.freepascal.org/index.php?topic=4978.0;wap2).

With persistent blocks you can easily mark text for later use as a
(second) kind of clipboard which is local to the file you are editing.

You can easily move to the beginning or end (in most implementations
even if the block is "hidden"/not visible). That works as a kind of "go
to last working area".

You can also set visually marks with it (because it's highlighted) so
that when you are srolling up or down you see immediately that you
crossed that part of text.

Jürgen.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Lazarus settings and roaming profiles in Windows

Luca Olivetti-2
In reply to this post by Vincent Snijders-2
En/na Vincent Snijders ha escrit:
> Jürgen Hestermann schreef:
>>>> Still I am wondering why the directory "Local Settings" is used and
>>>> not "Application Data" as all other applications do. Then it would
>>>> be saved with roaming profiles too.
>>> Luca Olivetti schrieb:
>>> http://bugs.freepascal.org/view.php?id=13908
>>
>> Interesting that noone mentioned the impact on roamed profiles. That's
>> definitely a drawback because you lose all your settings then!

They're not roaming but they're not lost (at least here).

>
> I am not sure having a 100 MB lazarus *roaming* profile by default would
> be a good idea.

My lazarus config directory is 254K under windows and 196K under linux.

Bye
--
Luca

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Lazarus settings and roaming profiles in Windows

Vincent Snijders-2
Luca Olivetti schreef:
>>
>> I am not sure having a 100 MB lazarus *roaming* profile by default
>> would be a good idea.
>
> My lazarus config directory is 254K under windows and 196K under linux.

I guess your lazarus directory is either writable or you didn't install
components. Otherwise you have a lazarus executable with your components
in <primary-config-path>/bin.

Vincent
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Lazarus settings and roaming profiles in Windows

Luca Olivetti-2
En/na Vincent Snijders ha escrit:

> Luca Olivetti schreef:
>>>
>>> I am not sure having a 100 MB lazarus *roaming* profile by default
>>> would be a good idea.
>>
>> My lazarus config directory is 254K under windows and 196K under linux.
>
> I guess your lazarus directory is either writable or you didn't install
> components. Otherwise you have a lazarus executable with your components
> in <primary-config-path>/bin.

Yes, my lazarus directory is writable. The configuration directory
doesn't seem to me a suitable place for the executable.
That's why under windows you have both CSIDL_APPDATA and
CSIDL_LOCAL_APPDATA.

Bye
--
Luca
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Lazarus settings and roaming profiles in Windows

Vincent Snijders-2
Luca Olivetti schreef:

> En/na Vincent Snijders ha escrit:
>> Luca Olivetti schreef:
>>>>
>>>> I am not sure having a 100 MB lazarus *roaming* profile by default
>>>> would be a good idea.
>>>
>>> My lazarus config directory is 254K under windows and 196K under linux.
>>
>> I guess your lazarus directory is either writable or you didn't
>> install components. Otherwise you have a lazarus executable with your
>> components in <primary-config-path>/bin.
>
> Yes, my lazarus directory is writable. The configuration directory
> doesn't seem to me a suitable place for the executable.
> That's why under windows you have both CSIDL_APPDATA and
> CSIDL_LOCAL_APPDATA.

Correct. And that is why if you have only one config dir, local app data
is maybe not so bad choice.

Vincent
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Lazarus settings and roaming profiles in Windows

Florian Klämpfl
In reply to this post by Vincent Snijders-2
Vincent Snijders schrieb:

> Jürgen Hestermann schreef:
>>>> Still I am wondering why the directory "Local Settings" is used and
>>>> not "Application Data" as all other applications do. Then it would
>>>> be saved with roaming profiles too.
>>> Luca Olivetti schrieb:
>>> http://bugs.freepascal.org/view.php?id=13908
>>
>> Interesting that noone mentioned the impact on roamed profiles. That's
>> definitely a drawback because you lose all your settings then!
>
> I am not sure having a 100 MB lazarus *roaming* profile by default would
> be a good idea.

I've a roaming profile of several GB at work. If you don't change your
working machine daily, this is no problem. Only if I log in into a
machine I never used before, it takes some minutes till the data is fetched.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Lazarus settings and roaming profiles in Windows

Vincent Snijders-2
Florian Klaempfl schreef:
> Vincent Snijders schrieb:
>> Jürgen Hestermann schreef:
>>> definitely a drawback because you lose all your settings then!
>> I am not sure having a 100 MB lazarus *roaming* profile by default would
>> be a good idea.
>
> I've a roaming profile of several GB at work. If you don't change your
> working machine daily, this is no problem. Only if I log in into a
> machine I never used before, it takes some minutes till the data is fetched.

Jürgen Hestermann, how often do you change your working machine?

Vincent
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Lazarus settings and roaming profiles in Windows

Luca Olivetti-2
In reply to this post by Vincent Snijders-2
En/na Vincent Snijders ha escrit:

>> Yes, my lazarus directory is writable. The configuration directory
>> doesn't seem to me a suitable place for the executable.
>> That's why under windows you have both CSIDL_APPDATA and
>> CSIDL_LOCAL_APPDATA.
>
> Correct. And that is why if you have only one config dir, local app data
> is maybe not so bad choice.

Well, I don't see why we can have only one config dir: windows offers
two (notwithstanding the fact that the whole roaming profile
implementation is moronic)

Bye
--
Luca
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
1234