Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » Time difference
Time difference [message #17254] Mon, 04 August 2008 23:24 Go to next message
captainc is currently offline  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 Go to previous messageGo to next message
mirek is currently offline  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
Re: Time difference -> Bug? [message #17256 is a reply to message #17255] Mon, 04 August 2008 23:59 Go to previous messageGo to next message
captainc is currently offline  captainc
Messages: 278
Registered: December 2006
Location: New Jersey, USA
Experienced Member
Hmm, thought so. I'll have to go for a generic years/months to seconds function.
Re: Time difference -> Bug? [message #17259 is a reply to message #17256] Tue, 05 August 2008 00:12 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
captainc wrote on Mon, 04 August 2008 17:59

Hmm, thought so. I'll have to go for a generic years/months to seconds function.


Ehm I wonder how much seconds has month? Smile

Mirek
Previous Topic: creating path
Next Topic: Drag & Drop Sample Size
Goto Forum:
  


Current Time: Fri Apr 19 10:19:50 CEST 2024

Total time taken to generate the page: 0.78982 seconds