Content deleted Content added
No edit summary |
No edit summary |
||
(One intermediate revision by one other user not shown) | |||
Line 528:
mimics templates {{Time/GMT offset}}, {{Time/EST offset}}, etc.
{{#invoke:Time
{{#invoke:Time
where <tz> is a timezone abbreviation known to Module:Time/data
returns a UTC offset string suitable for use with the {{#time:}} parser function:
{{#time:H:i | {{#invoke:Time
{{#time:H:i | {{UTC_offset|MST}} }}
Line 564:
local utc_offset;
local DST = first_set (cfg.aliases['dst'], args_t) or true; -- string 'always' or boolean
if is_set (tz.dst_begins) and is_set (tz.dst_ends) and is_set (tz.dst_time) then -- make sure we have all of the parts▼
if 'always' == DST then -- if needed to always display dst time
local dst_begin_ts, dst_end_ts, invert = make_dst_timestamps (timestamp); -- get begin and end dst timestamps and <invert> flag▼
elseif not yesno (DST) then -- for timezones that DO observe dst but for this ___location ...
if nil == dst_begin_ts or nil == dst_end_ts then -- if either of these are nil▼
return error_msg ({'UTC offset', cfg.err_text['bad_dst']}); -- abandon with error message▼
end▼
▲
▲ local dst_begin_ts, dst_end_ts, invert = make_dst_timestamps (timestamp); -- get begin and end dst timestamps and <invert> flag
if invert then -- southern hemisphere; use beginning and ending of standard time in the comparison▼
if utc_timestamp >= dst_end_ts and utc_timestamp < dst_begin_ts then -- is current date time standard time?▼
▲ utc_offset = tz.utc_offset; -- return timezone-offset from utc
else ▼
▲ utc_offset = apply_dst_ajdust (tz.utc_offset); -- return dst-adjusted timezone-offset from utc
end
else -- northern hemisphere▼
▲ if invert then
if utc_timestamp >= dst_begin_ts and utc_timestamp < dst_end_ts then -- is current date time daylight time?▼
▲ if utc_timestamp >= dst_end_ts and utc_timestamp < dst_begin_ts then -- is current date time standard time?
utc_offset = apply_dst_ajdust (tz.utc_offset); -- return dst-adjusted timezone-offset from utc▼
▲ else
▲ else
▲ utc_offset = tz.utc_offset; -- return timezone-offset from utc
▲ end
▲ if utc_timestamp >= dst_begin_ts and utc_timestamp < dst_end_ts then -- is current date time daylight time?
else
utc_offset = tz.utc_offset; -- return timezone-offset from utc
end
end
return error_msg ({'UTC offset', substitute (cfg.err_text['bad_def'], args_t[1]:upper())});▼
utc_offset = tz.utc_offset; -- return timezone-offset from utc
end
▲ elseif is_set (tz.dst_begins) or is_set (tz.dst_ends) or is_set (tz.dst_time) then -- if some but not all not all parts then emit error message
▲ return error_msg ({'UTC offset', substitute (cfg.err_text['bad_def'], args_t[1]:upper())});
▲ else -- timezone does not use dst
▲ utc_offset = tz.utc_offset; -- return timezone-offset from utc
end
|