Quote Originally Posted by Melanie
Here's the solution to item 2 from my previous post yesterday (as it's the easiest to complete). It's the inverse of the CalculateDateFromLinear subroutine.

This subroutine takes YEAR, MONTH and DAY and returns with Linear DAYS starting with DAYS=0 for 01/01/2000. Note, it's only good for 100 years as it does NOT account for year 2100 leap anomaly. I'm reusing variables and EEPROM presets previously defined in your program.

Code:
	'
	'	Subroutine Calculates Linear Days from Date
	'	-------------------------------------------
CalculateLinearFromDate:
	DAYS=0
	For CounterA=0 to YEAR
		TempA=CounterA//4
		If CounterA < YEAR then
			TempB=365
			If TempA=0 then TempB=TempB+1
			DAYS=DAYS+TempB
			endif
		Next CounterA
	IF MONTH > 1 then
		For CounterA=1 to MONTH-1
			Read (CounterA+20),ByteA
			If TempA=0 then
				If CounterA=2 then ByteA=ByteA+1
				endif
			DAYS=DAYS+ByteA
			Next CounterA
		endif
	DAYS=DAYS+DAY-1
	Return
Oh and in this routine, my MONTHS start counting from 1, so CounterA+20 is valid here!
I can't seem tp follow the variable delaration of the program
Can i use this with my DS1307 RTC
i can read YEAR, MONTH and DAY from my RTC what variable to i send them to before calling the sub.
i am confused here

Isaac