Sign in Join

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

Mailing lists / lazarus / 2009-04

TDateEdit.Date is not published...why?

14 messages · 7 people · –

Reply by email Subscribe to this list Your subscription

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

Graeme Geldenhuys

Hi,

Is there any specific reason why TDateEdit.Date is not published? That's kind of an important property for that component.

Is TDateEdit the equivalent to TDateTimePicker of Delphi's VCL?

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Vincent Snijders
to Vincent Snijders
Vincent Snijders wrote 10 lines
Graeme Geldenhuys schreef: > Hi, > > Is there any specific reason why TDateEdit.Date is not published? > That's kind of an important property for that component. > > You would have to ask Mattias and Aleksey: http://svn.freepascal.org/cgi-bin/viewvc.cgi?view=rev&root=lazarus&revision=10189

Googling for: Can somebody explain me the reasons behind the changes in revision 10189?
gives:
http:/msg12342.html

Vincent

Reply by email

Luca Olivetti
to Vincent Snijders

En/na Vincent Snijders ha escrit:

Show quoted text 15 lines
Vincent Snijders schreef: > Graeme Geldenhuys schreef: >> Hi, >> >> Is there any specific reason why TDateEdit.Date is not published? >> That's kind of an important property for that component. >> >> > You would have to ask Mattias and Aleksey: > http://svn.freepascal.org/cgi-bin/viewvc.cgi?view=rev&root=lazarus&revision=10189 Googling for: Can somebody explain me the reasons behind the changes in revision 10189? gives: http:/msg12342.html

As a side note, nulldate is actually set to a valid date (0 is 30/12/1899), not a common date in everyday use, but one could need it if, say, managing historical records.
Maybe a more sensible nulldate would be JulianDate or -DateDelta?

Bye

Luca Olivetti Wetron Automatizaci?n S.A. http://www.wetron.es/ Tel. +34 93 5883004 (Ext.133) Fax +34 93 5883007

Reply by email

Graeme Geldenhuys
to Vincent Snijders: Googling for: Can somebody explain me the reasons behind the changes in revision 10189?…
Vincent Snijders wrote 5 lines
Googling for: Can somebody explain me the reasons behind the changes in revision 10189? gives: http:/msg12342.html

OK, thanks Vincent.

And another reason DateTime and Currency should not be simply types. Lots of hacks are required to get null support, fix rounding issues etc... But that's a whole other topic. ;-)

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Graeme Geldenhuys
to Luca Olivetti: En/na Vincent Snijders ha escrit: As a side note, nulldate is actually set to a valid…
Luca Olivetti wrote
As a side note, nulldate is actually set to a valid date (0 is 30/12/1899), not a common date in everyday use, but one could need it

Hence my comment about TDateTime and Currency that are not supposed to have been simple types. :-) They are so flawed in design it's just scary. Try and do multi-currency calculations with a Currency type. Try and calculate the difference between dates or like you pointed out, setting it to a true null value. Thank goodness for Value Object design pattern. ;-)

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Graeme Geldenhuys
to Gerard N/A
Gerard N/A wrote
> scary. ?Try and do multi-currency calculations with a Currency type. Just out of ?curiosity, where's the problem?
Example #1
------------------
var
  cUSD: Currency;
  cGBP: Currency;
  cEuro: Currency;
  cSum: Currency;
begin
  cUSD := 1.00;
  cGBP := 1.00;
  cEuro := cUSD + cGBP;
  cSum := cUSD + cGBP;

Problem #1:
cEuro is only valid if exchange rate is 1:1. Which pretty much guaranteed not to be the case in this day and age.

Problem #2:
What currency is cSum in? Dollars or Pounds or something else?

...there are a few more issues like rounding, allocation of lost decimals in case of rounding errors, etc... :-) A simple type simply cannot handle such complex cases correctly.

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Gerard N/A
to Graeme Geldenhuys
Graeme Geldenhuys wrote 21 lines
Example #1 ------------------ var ?cUSD: Currency; ?cGBP: Currency; ?cEuro: Currency; ?cSum: Currency; begin ?cUSD := 1.00; ?cGBP := 1.00; ?cEuro := cUSD + cGBP; ?cSum := cUSD + cGBP; Problem #1: ? cEuro is only valid if exchange rate is 1:1. Which pretty ? much guaranteed not to be the case in this day and age. Problem #2: ? What currency is cSum in? ?Dollars or Pounds or something else?

I don't get it. Why would you add USD and GBP and assign the result to a variable wich is supposed to hold Euros?

...there are a few more issues like rounding, allocation of lost decimals in case of rounding errors, etc... ?:-) ?A simple type simply cannot handle such complex cases correctly.

Ok, maybe the name "currency" can be confusing. Curency is a fixed point real type with 4 decimal places.
Anyway, handling conversions between currencies requires more than even a simple class.
You would need to know at least what is the exchange rate for a given conversion.

Regards,

Gerard.

Reply by email

Graeme Geldenhuys
to Gerard N/A
Gerard N/A wrote
I don't get it. Why would you add USD and GBP and assign the result to a variable wich is supposed to hold Euros?

Think in terms of an accounting application that supports billing in multiple currencies. Or clients that pay there bills in there own currency, while the default currency is something else.

Ok, maybe the name "currency" can be confusing. Curency is a fixed point real type with 4 decimal places. Anyway, handling conversions between currencies requires more than even a simple class.

Exactly my point. :-)

You would need to know at least what is the exchange rate for a given conversion.

And the currency type and the rounding method use (maybe even per currency) and the preferred decimal numbers used (again maybe per currency) etc...

Something that seemed so simple in the beginning can become quite a complex task. ;-)

Now similar issue can be applied to TDateTime and String types. All I can say is thank goodness for Value Type Frameworks which get around these problems. Business objects are defined using class types instead of simple types. Anyway, this thread is getting a bit off-topic now.

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Gerard N/A
to Graeme Geldenhuys
Graeme Geldenhuys wrote 5 lines
Now similar issue can be applied to TDateTime and String types. ?All I can say is thank goodness for Value Type Frameworks which get around these problems. Business objects are defined using class types instead of simple types.

Indeed. My dream would be to have some sort of extendable RTTI or at least nulalble types.
A good VTF is a solution, in the meantime. ;-)

Regards,

Gerard.

Reply by email

Martin Schreiber
to Gerard N/A
Gerard N/A wrote
Indeed. My dream would be to have some sort of extendable RTTI or at least nulalble types.

MSEgui uses -Inf as null-TDatetime and null-double values which solves some of the problems.

Martin

Reply by email

Hans-Peter Diettrich
to Graeme Geldenhuys: Think in terms of an accounting application that supports billing in multiple currencies.…
Show quoted text 6 lines
> You would need to know at least what is the exchange rate for a given > conversion. And the currency type and the rounding method use (maybe even per currency) and the preferred decimal numbers used (again maybe per currency) etc...

Monetary calculations often are prescribed precisely, e.g. for taxes. These prescriptions as well as the preferred scaling are country specific. We just had a discussion about currencies where the base unit equals e.g. 1E-6 USD, where 64 bit and 4 decimal places are no more applicable, even for calculations in one currency.

Something that seemed so simple in the beginning can become quite a complex task. ;-) Now similar issue can be applied to TDateTime and String types.

Unlike other measure types (including date, temparature, length...), currencies have variable conversion rules or factors. In former days (some) currencies were based on gold or silver (Pound Sterling, Silverdollar, Goldmark...), usable as a common base for exchange calculations, but nowadays IMO all currencies are floating. Any fixed conversion methods will result in kind of weather forecast ;-)

DoDi

Reply by email

Leslie Kaye
to Hans-Peter Diettrich
Hans-Peter Diettrich wrote 30 lines
<div class="moz-text-flowed" style="font-family: -moz-fixed">Graeme Geldenhuys schrieb: >> You would need to know at least what is the exchange rate for a given >> conversion. > > And the currency type and the rounding method use (maybe even per > currency) and the preferred decimal numbers used (again maybe per > currency) etc... Monetary calculations often are prescribed precisely, e.g. for taxes. These prescriptions as well as the preferred scaling are country specific. We just had a discussion about currencies where the base unit equals e.g. 1E-6 USD, where 64 bit and 4 decimal places are no more applicable, even for calculations in one currency. > Something that seemed so simple in the beginning can become quite a > complex task. ;-) > > Now similar issue can be applied to TDateTime and String types. Unlike other measure types (including date, temparature, length...), currencies have variable conversion rules or factors. In former days (some) currencies were based on gold or silver (Pound Sterling, Silverdollar, Goldmark...), usable as a common base for exchange calculations, but nowadays IMO all currencies are floating. Any fixed conversion methods will result in kind of weather forecast ;-) DoDi

The Currency type is just a float with 4 decimal places and some special rounding behaviour that I cannot remember. Currency conversions and all the rest is up to you as a programmer and your application.

I think that TDateEdit.Date should be published. This is the behaviour of the JEDI TJvDateEdit and the Delphi date picker. If this exposes a bug then that is what needs to be fixed.

</div>

Reply by email