Home » U++ Library support » U++ Library : Other (not classified elsewhere) » Time difference
Time difference [message #17254] |
Mon, 04 August 2008 23:24 |
captainc
Messages: 278 Registered: December 2006 Location: New Jersey, USA
|
Experienced Member |
|
|
I have been using time difference to calculate time difference. I wanted to use a simple subtraction operation to subtract 1 hour from the current time.
Time t1 = GetSysTime();
Time dec(0,0,0,1,0,0);
Time res;
res.Set(t1-dec);
Cout() << "Time: " << AsString(t1) << "\n";
Cout() << "Time: " << AsString(res) << "\n";
Cout() << "Time: " << AsString(dec) << "\n";
result:Time: 08/04/2008 17:27:22
Dec: 00/00/ 0 01:00:00
Res: 07/04/2008 16:27:22
I was expecting 08/04/2008 16:27:22 and not 07/04/2008 16:27:22
Is Time not meant to be used in this way?
What if I specified it as:Time dec(1900,1,1,1,0,0); ?
[Updated on: Mon, 04 August 2008 23:59] Report message to a moderator
|
|
|
Re: Time difference -> Bug? [message #17255 is a reply to message #17254] |
Mon, 04 August 2008 23:56 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
captainc wrote on Mon, 04 August 2008 17:24 | I have been using time difference to calculate time difference. I wanted to use a simple subtraction operation to subtract 1 hour from the current time.
Time t1 = GetSysTime();
Time dec(0,0,0,1,0,0);
Time res;
res.Set(t1-dec);
Cout() << "Time: " << AsString(t1) << "\n";
Cout() << "Time: " << AsString(res) << "\n";
Cout() << "Time: " << AsString(dec) << "\n";
result:Time: 08/04/2008 17:27:22
Dec: 00/00/ 0 01:00:00
Res: 07/04/2008 16:27:22
I was expecting 08/04/2008 16:27:22 and not 07/04/2008 16:27:22
Is Time not meant to be used in this way?
What if I specified it as:Time dec(1900,1,1,1,0,0); ?
|
It is not. The start of time is "not specified", only delta is.
Try -3600.
Mirek
|
|
|
|
|
Goto Forum:
Current Time: Fri Apr 19 10:19:50 CEST 2024
Total time taken to generate the page: 0.78982 seconds
|