# Tell how many Days have passed with DS1307RTC

Hi there,

I'd like to specify a certain date via var and then output the number of days that have passed since then (Using DS1307RTC).

I'm thinking of something like this:
passedDays = rightNow - myDate

It is probably necessary to change the dates to the amount of seconds that have passed since 1970 to calculate them first, and afterwards change them back to actual days, right?

I'm using this library (linked via arduino.cc-playground): DS1307RTC Library, For Accessing Real Time Clock (RTC) Chips

Would love to know your opinion on how to do this the best way.

Thanks

It is probably necessary to change the dates to the amount of seconds that have passed since 1970 to calculate them first, and afterwards change them back to actual days, right?

That's one way. Probably the easiest.

The DS1307 has 56 bytes of battery backed SRAM.
Store whatever date you are using as the start date there.
Then do the math as you suggest.

Maybe use a later starting date - there’s already been 1356048000, or 0x50D3A680, seconds, plus several leap days (1972, 1976, 1980, 1984, 1988, 1992, 1996, 2000?, 2004, 2008, 2012) and leap seconds (need to look up when added), from 1/1/1970 to 12/31/2013.
So you’d need 4 bytes just store that offset.

Maybe use a later starting date - there's already been 1356048000, or 0x50D3A680, seconds, plus several leap days (1972, 1976, 1980, 1984, 1988, 1992, 1996, 2000?, 2004, 2008, 2012) and leap seconds (need to look up when added), from 1/1/1970 to 12/31/2013.

He'll also need to take daylight savings into account, if applicable. I understand that 1 leap second is added every year, but I may be wrong on that. It's because the earth's orbit is slowing down.

Leap years:
If year %4 =0...leap year...unless
year %100 = 0...not a leap year...unless
year %400 = 0...leap year
So 2000 was a leap year. 2100 won't be a leap year but 2400 will be.

What I don't understand is why he has to count in seconds when he only needs days. Surely, just counting (and storing) the number of days since 1/1/70 will be sufficient and a lot less complicated.

"Since the first leap second in 1972, all leap seconds have been positive and there were 23 leap seconds in the 34 years to January, 2006."
http://tycho.usno.navy.mil/leapsec.html
Agree, keep track of whole days up to say 12/1/2013, and go from there.
365 or 366 per year, known quantity in history now.

"Since the first leap second in 1972, all leap seconds have been positive and there were 23 leap seconds in the 34 years to January, 2006."
http://tycho.usno.navy.mil/leapsec.html
Agree, keep track of whole days up to say 12/1/2013, and go from there.
365 or 366 per year, known quantity in history now.

I think you meant EU 31/12/2013 [US 12/31/2013].

Yes, end of last year. Little typo.

Good evening, fine gentleman!

Thanks for your feedback. The leap seconds wont affect me, I think, since I'm just looking at a short period of time like 2-3 Months from now.

Will try my best, probably fail and then ask for help again, haha.

Thank you and have a good night!