Lasso Soft Inc. > Home

[pk_fourdigityear]

Linkpk_fourdigityear
AuthorPier Kuipers
CategoryDate
Version8.x
LicensePublic Domain
Posted21 Mar 2006
Updated21 Mar 2006
More by this author...

Description

This tag attempts to "intelligently" convert a date with a 2-digit year to its 4-digit equivalent. I wrote this tag to deal with users who entered their birthday using a 2-digit year, resulting in birth dates in the future, such as 2063-09-19.

Sample Usage

[pk_fourdigityear, -date='09/19/63'] -> 1963-09-19

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: 'fourdigityear', 
	-namespace = 'pk_',
	-description = 'converts a 2-digit year to a 4-digit year',
	-required = 'date';
	local:'output' = string;
	local:'tmp' = (date_format:#date, -format='%y-%m-%d');
	local:'datedata'=(#tmp->split:'-');
	local:'existingYear'=(string_findregexp: #date, -find='\\d{4}');
	if:((#existingYear -> size) > 0);
		local:'myYear' = (#existingYear -> get:1);
	else;
		local:'myYear' = (#datedata->get:1);
	/If;
	If:((#myYear -> size) == 2);
		local:'thisYear'=(date_format:(server_date), -format='%y');
		If:(#myYear > #thisYear);
			#myYear = '19' + #myYear;
		Else;
			#myYear = '20' + #myYear;
		/If;
	/If;
	#output = (#myYear + '-' + (#datedata->get:2) + '-' + (#datedata->get:3));
	return:#output;
/define_tag;

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