[duration2]

Description

Link: [duration2]
Author: Jason Huck
Category: Data Type
Version: 8.x
License: Public Domain
Posted: Jun. 12, 2006
Updated: May. 09, 2008
More by this author...
This is an alternate version of the built-in [duration] type (actually a subclass of it) whose member tags never round up -- they return the whole number of units of each type. Uses the plural form of each unit, i.e., ->seconds, ->minutes, ->hours, ->days, ->weeks, ->months, ->years. Otherwise identical to [duration].

Parameters

none


Sample Usage

duration2('00:30:01')->hours;

-> 0
						

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
26
27
28
29
30
31
32
33
define_type(
	'duration2', 'duration',
	-description='Alternate version of [duration] that never rounds up.'
);
	define_tag('seconds');
		return(self->second);
	/define_tag;

	define_tag('minutes');
		return(math_floor(self->second / 60));
	/define_tag;
	
	define_tag('hours');
		return(math_floor(self->second / 3600));
	/define_tag;
	
	define_tag('days');
		return(math_floor(self->second / 86400));
	/define_tag;
	
	define_tag('weeks');
		return(math_floor(self->second / 604800));
	/define_tag;
	
	define_tag('months');
		return(math_floor(self->days / 30.4375));
	/define_tag;
	
	define_tag('years');
		return(math_floor(self->days / 365.25));
	/define_tag;
/define_type;

 

Comments

none

Email:


Password:



Newest

Most Popular

Support tagSwap.net