[DT_Date]

Description

Link: [DT_Date]
Author: Rick Draper
Category: Date
Version: 8.x
License: Public Domain
Posted: Feb. 05, 2006
Updated: Feb. 05, 2006
More by this author...

This tag was created to overcome a problem where events were stored on one server in GMT, but expected to be presented in the time zone applicable to the local time of the event.  ie. taking into account daylight saving / summer time. 

The tag accepts a single date/time in Lasso GMT format. 

An array of Daylight Saving / Summer Time start and finish dates is required in GMT format.  eg. Var:'VIC_DST'=(array: (map:(DST_End)=(04/01/2006 17:00:00 GMT), (DST_Start)=(10/01/2005 16:00:00 GMT)), (map:(DST_End)=(03/26/2005 17:00:00 GMT), (DST_Start)=(10/30/2004 16:00:00 GMT)), (map:(DST_End)=(03/27/2004 17:00:00 GMT), (DST_Start)=(10/25/2003 16:00:00 GMT)))

The relevant offsets from GMT for Standard and Summer Time are set as parameters.

This is my first tag, so all feedback and suggestions will be most welcome.

Parameters

-Date_GMT date, required Date in GMT to be ouput in local time
-DST_Array array, required Array containing maps of Daylight Saving / Summer start / end dates - Must be in GMT eg. array: (map:(DST_End)=(04/01/2006 17:00:00 GMT), (DST_Start)=(10/01/2005 16:00:00 GMT)), (map:(DST_End)=(03/26/2005 17:00:00 GMT), (DST_Start)=(10/30/2004 16:00:00 GMT)), (map:(DST_End)=(03/27/2004 17:00:00 GMT), (DST_Start)=(10/25/2003 16:00:00 GMT))
-DST_Offset integer, required Summer Time GMT offset - Melbourne, Australia is 11
-DST_TZ string, required Daylight Saving / Summer Time Zone abbreviation (eg. AEDST)
-Format string, required Standard Lasso Date Format (eg. '%d %b %Y %h:%M%p' ... 04 Feb 2006 06:00AM)
-STD_Offset integer, required Standard GMT offset (ie. non-Summer Time) Melbourne, Australia is 10
-STD_TZ string, required Standard Time Zone abbreviation (eg. AEST)

Sample Usage

Var:'Display_Date'=
	(DT_Date:
	-Date_GMT=' '10/02/2005 02:00:00',
	-DST_Array=$VIC_DST,
	-STD_TZ='AEST',
	-STD_Offset=10,
	-DST_TZ='AEDST',
	-DST_Offset=11,
	-Format='%d %b %Y %h:%M%p');
						

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
Define_Tag:
'Date',
-Namespace='DT_',
-Required='Date_GMT',
-Type='Date',
-Required='DST_Array',
-Type='Array',
-Required='STD_Offset',
-Type='Integer',
-Required='STD_TZ',
-Type='String',
-Required='DST_Offset',
-Type='Integer',
-Required='DST_TZ',
-Type='String',
-Required='Format',
-Type='String'; 

Local:'Season_Set'=0;
Local:'Adjusted_Date'=(Date_Add:(#Date_GMT),-Hour=#STD_Offset);
Local:'Time_Zone'=#STD_TZ;

Iterate: #DST_Array, (Local: 'Date_Set');
	Local:'Start_GMT' = (#Date_Set->(Find:'DST_Start'));
	Local:'End_GMT' = (#Date_Set->(Find:'DST_End'));

	If:#Season_Set == 0;
		If:(Date_Difference: #Date_GMT, #Start_GMT, -Second) >= 0;
			#Season_Set = 1;
			If: (Date_Difference: #Date_GMT, #Start_GMT, -Second) >= 0 && (Date_Difference: #Date_GMT, #End_GMT, -Second) < 0;
				#Adjusted_Date = (Date_Add:#Date_GMT,-Hour=#DST_Offset);
				#Time_Zone = #DST_TZ;
			/If;
		/If;
	/If;
/Iterate;

Return:(Date_Format:#Adjusted_Date,-Format=#Format)+' '+#Time_Zone;
/Define_Tag;

 

Comments

none

Email:


Password:



Newest

Most Popular

Support tagSwap.net