Lasso Soft Inc. > Home

[lp_date_getLocalTimeZone]

Linklp_date_getLocalTimeZone
AuthorBil Corry
CategoryDate
Version8.x
LicensePublic Domain
Posted26 Feb 2006
Updated02 Mar 2006
More by this author...

Description

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]

Sample Usage

lp_date_getLocalTimeZone: (date:'2/10/2006'); // returns -0800 for Pacific timezone
'
'; 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.

[

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

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