Page Blocks

Hosting sponsored by:

Point In Space

 

API: Date

Filename:
fwpDate_age.ctag

Released With:
5.0.0

Current Version:
1.1.0

Status: Active

Min Lasso Tested: 8.1.0

Max Lasso Tested: 8.5.3

Related:

Still don't get it?

Check out the talk list archives, or join and ask your questions.

Documentation Error or Request?

Email documentation corrections or comments

API Reference

fwpDate_age (Tag)

Description

Returns an age in whole years based on supplied date string. The calculation can be based on the current date or an explicit supplied date.

Syntax

[fwpDate_age: -birthdate=dateString, -asOfDate=dateString]

A dateString is a string data type that Lasso accepts as a legal format for a date.

Parameters & Member Tags

-birthdate = required : the birthdate of the person, or if not being used for a person, the "starting" date of the time period to be aged.

-asOfDate = optional : the date as of which the age should be calculated. If not specified, will default to the server's current date.

Examples

[fwpDate_age: -birthdate=(field:'dbate')]

[fwpDate_age: -birthdate=(field:'dbate'), -asOfDate=$semesterEnd]

Source Code

View in separate window

<?lassoscript
//............................................................................
//
//    pageblocks: (c) 2002-2007 http://www.pageblocks.org/
//
//............................................................................
/*

    {fileName=        fwpDate_age.ctag }
    {rsrcType=        tag }
    {rsrcName=        fwpDate_age }
    {rsrcHTTP=        www.pageblocks.org/refc/fwpDate_age }

    {lassoVrsnMin=    8.1.0 }
    {lassoVrsnMax=    8.5.3 }

    {author=        Greg Willits }
    {authorEmail=    subscribe to pbTalk at www.pageblocks.org/talk/ }
    {authorHTTP=    www.pageblocks.org }

    {desc=            Returns an age based on supplied date (or today)
                     up to a limit of 105 years old as that is 
                     about the limit of an integer in seconds }

    {maintvsrn=        1.1 }
    {maintrelease=    5.1.7 }
    {maintdate=        2007-05-26 }
    {maintauthor=    Greg Willits }
    {maintnotes=    updated for changes to date handling introduced in 8.5.2
                    and generally cleaned up and simplified }

    {maintvsrn=        1.0 }
    {maintrelease=    5.0.0 }
    {maintdate=        2006-01-16 }
    {maintauthor=    Greg Willits }
    {maintnotes=    initial release }

*/
//.............................................................................

define_tag:'fwpDate_age', 
    -priority = 'replace',
    -required = 'birthdate',
    -optional = 'asOfDate';
    
    local:'asOfDate'  = local:'asOfDate';
    
    (#asOfDate == '') || (#asOfDate >> '0000')
        ? #asOfDate = date;

    (#birthDate != '') && (#birthDate !>> '0000') 
    && (#asOfDate != '') && (#asOfDate !>> '0000')
    && (valid_date: #birthdate) && (valid_date: #asOfDate)
        ? return: math_floor: ((date:#birthDate)->(difference: (date:#asOfDate), -second)) / (3600 * 24 * 365.25);

/define_tag;
?>


© 2002-2010, pageblocks.org