[lp_date_getLocalTimeZone]

Description

Link: [lp_date_getLocalTimeZone]
Author: Bil Corry
Category: Date
Version: 8.x
License: Public Domain
Posted: Feb. 26, 2006
Updated: Mar. 02, 2006
More by this author...
Returns the timezone offset for the local server.  Optionally may specify a date to take DST into account.

Requires [lp_date_stringtodate] [lp_string_pad] [lp_date_serverDST] [lp_date_stringToOffset]

Parameters

-date date, optional Optional date to evaluate timezone offset. Default is to use current date.

Sample Usage

lp_date_getLocalTimeZone: (date:'2/10/2006'); // returns -0800 for Pacific timezone
'<br>';
lp_date_getLocalTimeZone: (date:'6/10/2006'); // returns -0700 for Pacific timezone
						

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
35
36
37
38
39
40
41
42
43
44
[

define_tag:'lp_date_getLocalTimeZone',
	-description='Returns the timezone offset for the local server.  Optionally may specify a date to take DST into account.',
	-priority='replace',
	-optional='date',-copy;

	// does not have a -long option, like it's Lasso counterpart [Date_GetLocalTimeZone]

	if: !(local_defined:'date');
		local:'date' = date;
	/if;

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

	if: (lp_date_serverDST: date) && (lp_date_serverDST: #date); // if same, easy
		return: (lp_date_stringToOffset: Date_GetLocalTimeZone);
	else: !(lp_date_serverDST: date) && !(lp_date_serverDST: #date); // if same, easy
		return: (lp_date_stringToOffset: Date_GetLocalTimeZone);
	else: (lp_date_serverDST: date) && !(lp_date_serverDST: #date); // server in DST, date is not

		local:'hour' = (lp_date_stringToOffset: Date_GetLocalTimeZone, -map)->(find:'hours');
		#hour -= 1; // correct for DST
		local:'minute' = (lp_date_stringToOffset: Date_GetLocalTimeZone, -map)->(find:'minutes');

		// return offset with DST taken into account
		return: (lp_date_stringToOffset: (string:#hour) (lp_string_pad: #minute,2));

	else; // !(lp_date_serverDST: date) && (lp_date_serverDST: #date); //server not in DST, date is
	
		local:'hour' = (lp_date_stringToOffset: Date_GetLocalTimeZone, -map)->(find:'hours');
		#hour += 1; // correct for DST
		local:'minute' = (lp_date_stringToOffset: Date_GetLocalTimeZone, -map)->(find:'minutes');

		// return offset with DST taken into account
		return: (lp_date_stringToOffset: (string:#hour) (lp_string_pad: #minute,2));

	/if;

/define_tag;

]

 

Related Tags



Comments

none

Email:


Password:



Newest

Most Popular