Lasso Soft Inc. > Home

[lp_date_toOffset]

Linklp_date_toOffset
AuthorBil Corry
CategoryDate
Version8.x
LicensePublic Domain
Posted26 Feb 2006
Updated06 Sep 2006
More by this author...

Description

Returns the date at a specified timezone offset given a date in either UTC/GMT or local server timezone.

Requires [lp_date_stringtodate] [lp_date_localToUTC] [lp_string_getnumeric] [lp_date_stringToOffset]

Sample Usage

(lp_date_toOffset: (date:'2/20/2006 12:00:00 GMT'), '-0500'); // returns 2/20/2006 07:00:00
'
'; (lp_date_toOffset: (date:'2/20/2006 12:00:00'), '-0500'); // returns 02/20/2006 15:00:00 for server local time offset of -0800

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_tag:'lp_date_toOffset',
	-description='Returns the date at a specified timezone offset given a date in either UTC/GMT or local server timezone.',
	-priority='replace',
	-required='date',-copy,
	-required='timezone_offset';

	// get date
	
		if: #date->type != 'date';
			#date = lp_date_stringtodate: (string: #date);
		/if;

	// convert to UTC/GMT
	
		#date = lp_date_localToUTC: #date;

	// remove UTC/GMT marker
		
		#date = (date: #date->month '/' #date->day '/' #date->year ' ' #date->hour ':' #date->minute ':' #date->second);	

	// return date at offset
		local:'hour' = (lp_date_stringToOffset: #timezone_offset, -map)->(find:'hours');
		local:'minute' = (lp_date_stringToOffset: #timezone_offset, -map)->(find:'minutes');
		if: (string:#timezone_offset)->(contains:'-');
			#minute *= -1;
		/if;

		return: (date_add: #date, -hour=#hour, -minute=#minute);

/define_tag;

]

Related Tags

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