-
April 29th, 2013, 05:35 AM
#1
DateTime weird
Trying to estimate when a test will end
Code:
DateTime EndTime = new DateTime(DateTime.Now.Ticks + NTests * 20000000);
This gives me an end time lower than DateTime.Now !?!? Thought it was caused by long overflow, but no result is lower than 9,223,372,036,854,775,807. Any idea what might be wrong here ?
-
April 30th, 2013, 12:39 PM
#2
Re: DateTime weird
Why will you need Ticks? Its nanoseconds from 1970. Why will you add to that? You can simply take the current time and if you know Ntests and how much time each test takes, then that can be added to current time.
-
April 30th, 2013, 12:40 PM
#3
Re: DateTime weird
Actually a single tick is 100 nano secs based on MSDN and ist from the start of the century not 1970.
-
April 30th, 2013, 08:50 PM
#4
Re: DateTime weird
How are you determining that it is lower than DateTime.Now (and which "now" do you mean?)
Best Regards,
BioPhysEngr
http://blog.biophysengr.net
--
All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.
-
April 30th, 2013, 10:37 PM
#5
Re: DateTime weird
Explain what you are trying to calculate... Not at all clear?
-
May 6th, 2013, 04:53 PM
#6
Re: DateTime weird
Any chance you're testing along the lines of: DateTime.Now < EndTime?
Because, that "Now" is a new "Now", and not the original "Now".
If so, you need to store the result of DateTime.Now the first time you call it, and check against that.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|