As we all know, Julian Date was fixed by Julius Caesar, this was a guy that played with PICs a lot - and look where it got him. The problem we have is that PBP doesn’t handle Roman Numerals too well, and whilst the idea of having a Linear Date is a good (and very useful) one, generally, we only have to handle the Century that we’re in. So let’s start our PIC’s handling of a Linear Date from 1st January 2000... this way an integer variable (counting in DAYS) can ‘theoretically’ handle over 170 years worth of data.

Now I don’t know about you, but it’s highly unlikely that any of my designs are still going to be working in the year 2170 (in best engineering tradditions they're only guaranteed to work until the warranty expires), and I’m sure not going to be fielding the tech-support calls. If you find that the date gets screwed past 05/06/2179 (integer value 65534), don't email me - I'm not interested.

Converting Linear DAYS Back to a Date in the form of YEAR, MONTH and DAY is a little tricky... This is a clumsy way of working out the result, however, the routine I actually use I’m not willing to share, so you’ll have to make do with this one I threw together this morning... starting at January 1 2000 it’s good for almost 180 years (and being a thoughtful kinda girl, I've accounted for the fact that Year 2100 is NOT a Leap Year)...

The Subroutine shares variables that I've used earlier in this thread, and is called with the Linear Date held in the variable DAYS, and returns with a useable YEAR, MONTH and DAY.

Code:
	CounterA var BYTE
	DAY var BYTE
	DAYS var WORD
	MONTH var BYTE
	TempA var WORD
	TempB var WORD
	YEAR var BYTE

	'
	'	Subroutine Calculates Date from Linear Days
	'	-------------------------------------------
CalculateDateFromLinear:
	YEAR=0
	DAYS=DAYS+1 
	For CounterA=4 to 183
		TempA=CounterA//4
		TempB=365
		If TempA=0 then 
			If CounterA<>104 then TempB=TempB+1
			endif
		If DAYS>TempB then 
			YEAR=YEAR+1
			DAYS=DAYS-TempB
			else
			Goto CalculateMonth
			endif
		Next CounterA
	' add 2000 to the YEAR value, ie YEAR=4 implies 2004.
CalculateMonth:
	MONTH=0
CalculateMonthLoop:
	Lookup2 MONTH,[31,28,31,30,31,30,31,31,30,31,30,31],DAY
	IF TempA=0 then
		IF YEAR<>100 then
			If MONTH=1 then DAY=DAY+1
			Endif
		Endif
	If DAYS>DAY then
		DAYS=DAYS-DAY
		MONTH=MONTH+1
		Goto CalculateMonthLoop
		Endif
	MONTH=MONTH+1
	DAY=DAYS
	Return
Melanie