Home
Products
Community
Manuals
Contact
Login or Signup

Code archives/Algorithms/Conversion Log Date

This code has been declared by its author to be Public Domain code.

Download source code

Conversion Log Date by Sonari Eclipsi Onimari(Posted 1+ years ago)
This is kinda like the Startrek Stardate. Useful for telling people certain dates in secrecy. I know its kinda stupid, but its fun because people always want to know the day, I just tell them the CLD...
Function cld()
	year=Right$(CurrentDate(),4)
	ny=year-2000;this means that it will work until 3000 A.D. (The world will collapse before then according to the signs..)
	;2005 now = 5
	ny=ny-1
	;compensate for the following year
	;5 now = 4
		;2004=leapyear
		
			kip#=Float(ny/4)
			If kip# > ny And kip# < kip#+1
				;not leap year
				ly=False
				kip#=Left(kip#,1)
				;now, add # of years
					dcld=365*ny
						dcld=dcld+kip#
						;now, how many days this year
							month$=Mid(CurrentDate(),4,3)
								Select month$
									Case "Jan"	
										dcld=dcld+day
									Case "Feb"
										dcld=dcld+(31+day)
									Case "Mar"
										dcld=dcld+(31+28+day)
									Case "Apr"
										dcld=dcld+(31+28+31+day)
									Case "May"
										dcld=dcld+(31+28+31+30+day)
									Case "Jun"
										dcld=dcld+(31+28+31+30+31+day)
									Case "Jul"
										dcld=dcld+(31+28+31+30+31+30+day)
									Case "Aug"
										dcld=dcld+(31+28+31+30+31+30+31+day)
									Case "Sep"
										dcld=dcld+(31+28+31+30+31+30+31+31+day)
									Case "Oct"
										dcld=dcld+(31+28+31+30+31+30+31+31+30+day)
									Case "Nov"
										dcld=dcld+(31+28+31+30+31+30+31+31+30+31+day)
									Case "Dec"
										dcld=dcld+(31+28+31+30+31+30+31+31+30+31+30+day)
								End Select
								
						
			Else
				;yup, its leap year
				ly=True 
				kip#=Left(kip#,1)
				;now, add # of years
					dcld=365*ny
						dcld=dcld+kip#
						;now, how many days this year so far
						month$=Mid(CurrentDate(),4,3)
								Select month$
									Case "Jan"	
										dcld=dcld+day
									Case "Feb"
										dcld=dcld+(31+day)
									Case "Mar"
										dcld=dcld+(31+29+day)
									Case "Apr"
										dcld=dcld+(31+29+31+day)
									Case "May"
										dcld=dcld+(31+29+31+30+day)
									Case "Jun"
										dcld=dcld+(31+29+31+30+31+day)
									Case "Jul"
										dcld=dcld+(31+29+31+30+31+30+day)
									Case "Aug"
										dcld=dcld+(31+29+31+30+31+30+31+day)
									Case "Sep"
										dcld=dcld+(31+29+31+30+31+30+31+31+day)
									Case "Oct"
										dcld=dcld+(31+29+31+30+31+30+31+31+30+day)
									Case "Nov"
										dcld=dcld+(31+29+31+30+31+30+31+31+30+31+day)
									Case "Dec"
										dcld=dcld+(31+29+31+30+31+30+31+31+30+31+30+day)
								End Select
				EndIf 
			Return dcld
End Function

Comments

Sonari Eclipsi Onimari(Posted 1+ years ago)
I forgot, add the following to the top of the code:

day=left(currentdate(),2)



Cold Harbour(Posted 1+ years ago)
There's also an algo called Rata Die that may be useful:
	If m < 3 
		m=m+12
		y = y - 1
	End If
	
	rd = d + (153 * m - 457)/ 5 + 365 * y + y / 4 - y / 100 + y / 400 - 306


where y is four digit year like 2005.


Code Archives Forum