[pk_fourdigityear]

Description

Link: [pk_fourdigityear]
Author: Pier Kuipers
Category: Date
Version: 8.x
License: Public Domain
Posted: Mar. 21, 2006
Updated: Jan. 01, 0001
More by this author...
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.

Parameters

-date string, required

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.
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
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

none

Email:


Password:



Newest

Most Popular

Support tagSwap.net