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
|
if(!lasso_tagexists('vz_elapsedtime'));
define_tag('elapsedtime',
-description='given a date and optional time, this tag will return a string displaying its offset compared to the current time in the format "[n] [units] ago".',
-namespace='vz_',
-required='datetime',
-Priority='Replace');
local('timenow'=date);
local('output'=string);
local('timespans'=(array('year', 'month', 'week', 'day', 'hour', 'minute', 'second')));
iterate(#timespans, local('tmp'));
local('diff'=(date_difference(#timenow, #datetime, #tmp)));
if(#diff > 0);
if((#tmp=='day')&&(#diff==1));
#output = 'yesterday';
else;
#output = #diff+' '#tmp+(#diff>1?'s')+' ago';
/if;
loop_abort;
/if;
/iterate;
return(@#output);
/define_tag;
/if;
|