[lp_date_leapyear]

Description

Link: [lp_date_leapyear]
Author: Bil Corry
Category: Date
Version: 8.x
License: Public Domain
Posted: Dec. 02, 2005
Updated: Dec. 03, 2005
More by this author...
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.

Parameters

-year integer, optional Year to check if it's a leap year. May also pass in a [date] instead.

Sample Usage

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

[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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
[

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

none

Email:


Password:



Newest

Most Popular