[lp_date_toOffset]

Description

Link: [lp_date_toOffset]
Author: Bil Corry
Category: Date
Version: 8.x
License: Public Domain
Posted: Feb. 26, 2006
Updated: Sep. 06, 2006
More by this author...
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]

Parameters

-date date, required Date to convert to offset. Can either be local server time or GMT/UTC time.
-timezone_offset string, required Timezone offset. In format of +hhmm or -hhmm.

Sample Usage

(lp_date_toOffset: (date:'2/20/2006 12:00:00 GMT'), '-0500'); // returns 2/20/2006 07:00:00
'<br>';
(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.
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
34
[

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

none

Email:


Password:



Newest

Most Popular

Support tagSwap.net