Link | pk_fourdigityear |
Author | Pier Kuipers |
Category | Date |
Version | 8.x |
License | Public Domain |
Posted | 21 Mar 2006 |
Updated | 21 Mar 2006 |
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.
[pk_fourdigityear, -date='09/19/63'] -> 1963-09-19
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;
No comments
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft