CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

date/time difference display

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
altra22



Joined: 14 May 2007
Posts: 11

View user's profile Send private message

date/time difference display
PostPosted: Sat Jul 17, 2010 9:51 am     Reply with quote

Hi, I am doing project to display difference between two dates in days/hours/min/sec.
My date is 1924 till this moment a count up timer.
I searched the forum and I see this: routine
But Author says
Quote:

/******* Adapted for years 2001 to 2135 (limited by size of int32) ******/

How can I get the difference between these dates 3/3/1924 -> today

Any ideas?
Thanks in advance
Ttelmah



Joined: 11 Mar 2010
Posts: 19546

View user's profile Send private message

PostPosted: Sun Jul 18, 2010 2:13 am     Reply with quote

Basically, the 'core' of what you need is there.
The reason the formulae there are limited to this century, is simply that they only use the last two digits of the year, and that the leap year calculator doesn't use the full formula. However the full formula is published later in the thread.
Now, there is an overall limitation, that these formulae can only cover 136 years, since past this, the number of seconds goes beyond an int32...

So, start with the formulae published.
Offset back by 100 years. So 1924, becomes '24', 2010, becomes '110' etc. The day of week calculator will need '19', instead of '20' as the century.
Modify the 'leap year' calculation to allow for the year 2000 (100 as an incoming year number).

The alternative is to switch to using full int16 year numbers, but offsetting will still be needed because of the 136 year limit, so you might as well stick with int8, and use 1900 as the origin.

Best Wishes

Potentially this will cover 1901 to 2035 inclusive
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group