Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, November 2006
QDateTime::setTime_t (QDateTime::toTime_t ()) confuses QDateTime calculations


Message 1 in thread

I just noticed a possible bug in QDateTime calculations:

QDateTime dt = QDateTime::currentDateTime ();
qDebug ("dt: %s", dt.toString ().toLocal8Bit ().constData ());
qDebug ("toTime_t: %u", dt.toTime_t ());
dt.setTime_t (dt.toTime_t ());
qDebug ("after _t dt: %s", dt.toString ().toLocal8Bit ().constData ());
qDebug ("toTime_t: %u", dt.toTime_t ());

dt.setDate (dt.date ().addDays (-21));
qDebug ("dt: %s", dt.toString ().toLocal8Bit ().constData ());
dt.setTime (QTime (0, 0));
qDebug ("dt: %s", dt.toString ().toLocal8Bit ().constData ());
dt = dt.addSecs (1);
qDebug ("dt: %s", dt.toString ().toLocal8Bit ().constData ());

qDebug (">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");

dt = QDateTime::currentDateTime ();
qDebug ("dt: %s", dt.toString ().toLocal8Bit ().constData ());
qDebug ("toTime_t: %u", dt.toTime_t ());

dt.setDate (dt.date ().addDays (-21));
qDebug ("dt: %s", dt.toString ().toLocal8Bit ().constData ());
dt.setTime (QTime (0, 0));
qDebug ("dt: %s", dt.toString ().toLocal8Bit ().constData ());
dt = dt.addSecs (1);
qDebug ("dt: %s", dt.toString ().toLocal8Bit ().constData ());

produces following output:

dt: Thu Nov 2 00:43:11 2006
toTime_t: 1162424591
after _t dt: Thu Nov 2 00:43:11 2006
toTime_t: 1162424591
dt: Thu Oct 12 00:43:11 2006
dt: Thu Oct 12 00:00:00 2006
dt: Thu Oct 12 01:00:01 2006
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
dt: Thu Nov 2 00:43:11 2006
toTime_t: 1162424591
dt: Thu Oct 12 00:43:11 2006
dt: Thu Oct 12 00:00:00 2006
dt: Thu Oct 12 00:00:01 2006

On timezone Europe/Berlin

After calling:

dt.setTime_t (dt.toTime_t ());

adding a single second actually adds an hour and a  second.

Bug report is filed.

Frank

--
 [ signature omitted ] 

Message 2 in thread

Tested on linux, windows
Timezone Europe/Berlin

Further research on this issue leads to the following:

Setting QDateTime to a specific value and calling addSecs () before a call to
setDate () that shifts over the daylight-savings border mixes up timestamp/daylight savings.

If addSecs is called before setDate (), daylight savings seem to be ignored.
Only if addSecs (), even with value '0', is called afterwards, the daylight-savings state is in order again.

Frank

--
 [ signature omitted ] 

Message 3 in thread

So I went out and bought the book "C++ GUI Programming with Qt 4" 
byBlanchette and Summerfield.  It seems ok.  However, I'm following 
along, have gotten to page 30 where we use QtDesigner to make an 
expandable button box.  So I launch QtDesigner, no problem, then try to 
follow the instructions:

1.  Click File|New Form and choose the "Dialog with Buttons Right" template.

Ok, no problem.

2.  Create the "More" button and drag it into the vertical layout, below 
the vertical spacer.  Set the "More" button's text property to &more, 
and its checkable prperty to true.

Well, I can create the More button, but there's no way to add it to the 
button box / layout created by the template

2 (cont'd):  Set the OK button's default property to "true."

There's no way to access the Ok button.  All I can do is access the 
"buttonBox" properties.  That's the box containing the Ok and Cancel 
buttons respectively. 

So either I'm missing something subtle, or the book is quite simply 
wrong and I need to get my $60 back.

I've tried combinations of Apple, Option, Shift and Control clicking the 
button box in the hope's of being able to access the individual button 
properties.  No dice.

Input / advice / comments appreciated.

Thanks,

DT

--
 [ signature omitted ] 

Message 4 in thread

Sry for private message. Now I've checked all with Qt 4.2. It doesn't work... true, but this book is written when Qt 4.1 came up, so everything works well with 4.1.x. And with Qt 4.2 there is new object called QButtonBox, and it's used instead of Vertical Layout with all thos buttons placed "manualy". So all you have to do (using Qt 4.2 of course) is creating your own "Button Box" with QVerticalLayout.

> So I went out and bought the book "C++ GUI Programming with Qt 4" 
> byBlanchette and Summerfield.  It seems ok.  However, I'm following 
> along, have gotten to page 30 where we use QtDesigner to make an 
> expandable button box.  So I launch QtDesigner, no problem, then try to 
> follow the instructions:
> 
> 1.  Click File|New Form and choose the "Dialog with Buttons Right" template.
> 
> Ok, no problem.
> 
> 2.  Create the "More" button and drag it into the vertical layout, below 
> the vertical spacer.  Set the "More" button's text property to &more, 
> and its checkable prperty to true.
> 
> Well, I can create the More button, but there's no way to add it to the 
> button box / layout created by the template
> 
> 2 (cont'd):  Set the OK button's default property to "true."
> 
> There's no way to access the Ok button.  All I can do is access the 
> "buttonBox" properties.  That's the box containing the Ok and Cancel 
> buttons respectively. 
> 
> So either I'm missing something subtle, or the book is quite simply 
> wrong and I need to get my $60 back.
> 
> I've tried combinations of Apple, Option, Shift and Control clicking the 
> button box in the hope's of being able to access the individual button 
> properties.  No dice.
> 
> Input / advice / comments appreciated.
> 
> Thanks,
> 
> DT
> 
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
> 

--
 [ signature omitted ] 

Message 5 in thread

On Thursday 02 November 2006 16:33, Frank Hemer wrote:
> Setting QDateTime to a specific value and calling addSecs () before a call
> to setDate () that shifts over the daylight-savings border mixes up
> timestamp/daylight savings.
>
> If addSecs is called before setDate (), daylight savings seem to be
> ignored. Only if addSecs (), even with value '0', is called afterwards, the
> daylight-savings state is in order again.

Now has assigned tasktracker id: #137698

Frank

--
 [ signature omitted ]