[Lazarus] Date value 0
Kamen Ketev
kamenlist at abv.bg
Wed May 27 13:25:34 CEST 2015
It works only if you don't use time. Please look at example:
var t, dt: TDateTime;
i: integer;
s1, s2, s3, s4, s5, s6 : String;
begin
t := StrToDate('30.12.1899');
i := round (t);
s1 := DateTimeToStr(t);
s2 := IntToStr(i);
t := StrToDate('29.12.1899');
i := round (t);
s3 := DateTimeToStr(t);
s4 := IntToStr(i);
dt := StrToDate('29.12.1700') + StrToTime('18:00:55');
s5 := FormatDateTime('dd.mm.yyyy hh.nn.ss', dt);
s6 := IntToStr(i);
Memo1.Lines.Add (s1 + ' ' + s2 + ' ' + s3 + ' ' + s4 + ' ' + s5 + ' ' + s6);
provides
30.12.1899 0 29.12.1899 -1 30.12.1700 05.59.05 -1
Date add 1 day, time not correct
If you change date to 29.12.1900 it is ok:
30.12.1899 0 29.12.1899 -1 29.12.1900 18.00.55 -1
If you change date to 29.12.1700 and time to '8:00:55' provides:
30.12.1899 0 29.12.1899 -1 30.12.1700 15.59.05 -1
If you change date to 29.12.1900 and time to '8:00:55' provides ok:
30.12.1899 0 29.12.1899 -1 29.12.1900 08.00.55 -1
If you change date to 29.12.19 and time to '8:00:55' provides:
29.12.2019 08.00.55 -1
(not 19 year)
If you change date to 29.12.0019 and time to '8:00:55' provides:
30.12.0019 15.59.05 -1
Year is ok, but date and time not. But how I can add value in TSpinEdit 0019? I am using it because in components TDateEdit, TDateTimePicker date must be between 24.9.1752 and 31.12.9999.
If you change date to 29.12.-1900: EConvertError: not a valid date format. How can I use date before 0000 year?
Regards,
Kamen
-------- Оригинално писмо --------
От: Michael Schnell
Относно: Re: [Lazarus] Date value 0
До: lazarus at lists.lazarus.freepascal.org
Изпратено на: Сряда, 2015, Май 27 11:44:17 EEST
For me it works as expcted
var t: TDateTime;
i: integer;
s1, s2, s3, s4 : String;
begin
t := StrToDate('30-12-1899');
i := round (t);
s1 := DateTimeToStr(t);
s2 := IntToStr(i);
t := StrToDate('29-12-1899');
i := round (t);
s3 := DateTimeToStr(t);
s4 := IntToStr(i);
Memo1.Lines.Add (s1 + ' ' + s2 + ' ' + s3 + ' ' + s4);
provides
30-12-99 0 29-12-99 -1
-Michael
--
_______________________________________________
Lazarus mailing list
Lazarus at lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20150527/fed89f49/attachment-0003.html>
More information about the Lazarus
mailing list