Lasso Soft Inc. > Home

[duration2]

Linkduration2
AuthorJason Huck
CategoryData Type
Version8.x
LicensePublic Domain
Posted12 Jun 2006
Updated09 May 2008
More by this author...

Description

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

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.

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

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft