Link | lp_date_leapyear |
Author | Bil Corry |
Category | Date |
Version | 8.x |
License | Public Domain |
Posted | 02 Dec 2005 |
Updated | 03 Dec 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.
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]
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; ]
No comments
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft