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;
]
|