Lasso Soft Inc. > Home

[lp_date_leapyear]

Linklp_date_leapyear
AuthorBil Corry
CategoryDate
Version8.x
LicensePublic Domain
Posted02 Dec 2005
Updated03 Dec 2005
More by this author...

Description

Given a year (or date), it returns true if it is a Gregorian leap year, or false if it is not.  If no year is passed, it assumes the current year.

Sample Usage

LeapYear Example
[loop: -from=1800, -to=2200][if: (lp_date_leapyear: loop_count)]
[loop_count] is a leap year[/if][/loop]
[lp_date_leapyear] [lp_date_leapyear: date]

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.

[

define_tag:'lp_date_leapyear',
	-description='Given a year (or date), it returns true if it is a Gregorian leap year, or false if it is not.  If no year is passed, it assumes the current year.',
	-priority='replace',
	-optional='year',-copy;

	// gregorian leap year algorithm from http://mindprod.com/jglossleapyear.html (now MIA)
	// valid roughly from 1800 forward 

	if: !(local_defined:'year');
		local:'year' = date;
	/if;

	if: #year->type == 'date';
		#year = (integer: #year->year);
	else; // assume integer year
		#year = integer: #year;
	/if;

	if: #year % 4 != 0;
		return: false;
	else: #year % 100 != 0;
		return: true; 
	else: #year % 400 != 0;
		return: false;
	else;
		return: true;
	/if;

/define_tag;

]

Related Tags

Comments

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft