Lasso Soft Inc. > Home

[lp_date_offsetToUTC]

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

Description

Returns the date at UTC/GMT given a date with a specified timezone offset.

Requires [lp_date_stringtodate] [lp_string_getnumeric] [lp_date_stringtoOffset]

Sample Usage

(lp_date_offsetToUTC: (date:'2/20/2006 7:00:00'), '-0500'); // returns 02/20/2006 12:00:00 GMT

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_offsetToUTC',
	-description='Returns the date at UTC/GMT given a date with a specified timezone offset.',
	-priority='replace',
	-required='date',-copy,
	-required='timezone_offset';

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

	#date = (lp_date_utcToLocal: #date);

	local:'offset' = (lp_date_stringToOffset: #timezone_offset, -map);

	local:'hour' = #offset->(find:'hours');
	local:'minute' = #offset->(find:'minutes');
	if: (string:#timezone_offset)->(contains:'-');
		#minute *= -1;
	/if;

	#hour *= -1;
	#minute *= -1;

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

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

	return: #date;

/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