[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Re: KSpread: Value::asDateTime oddity
From:       "Tomas Mecir" <mecirt () gmail ! com>
Date:       2006-12-29 17:43:28
Message-ID: 492258b10612290943u63873e84ieb1e5435fa6e0494 () mail ! gmail ! com
[Download RAW message or body]

2006/12/29, Stefan Nikolaus <stefan.nikolaus@kdemail.net>:
> Hi all,
>
> the definition of Value::asDateTime looks very strange. It composes the date
> and the time of the same integer value. I expected the time to be the
> non-integer part of the floating point value. Anyone, who's able to let my
> concerns end up in smoke (no farts, please. enough wind here ;) )?

Nobody, the code is wrong. The representation used to be such that the
integer portion was for date and the decimal portion was for time.
This got changed, and asDateTime is a left-over that nobody fixed.
Note that this:
void Value::setValue( const QDateTime& dt, const Doc* doc  )
{
  QDate refDate( doc->referenceDate() );
  QTime refTime( 0, 0 );

  int i = refDate.daysTo( dt.date() );
  i += refTime.secsTo( dt.time() ) / 86400;

  setValue( i );
  d->format = fmt_DateTime;
}

seems to be totally wrong as well.
The correct representation would be to store dates and times as
seconds since Epoch, and to always do so that way, even if we only
store date (time is 0 then), or only time (date is I-don't-know-what
then, probably today's date).

Also note that I'm unsure whether asDateTime ever gets used anywhere.

/ Tomas
_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic