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.
<?LassoScript
/**!
tzconvert
Method to set datetime values to specific timezones. Can also convert datetime values from the input timezone to the output.
Params are:
date Input date, required
-tz_in What timezone the input date is to be treated as. If not set will use the timezone from the input date
-tz_out What timezone the output date should be set to. Defaults to GMT
-format Format used for the output date. Defaults to %Q %T (2011-08-26 12:58:27)
-convert If true will convert the input date to a value corresponding to the output timezone. Defaults to false
NOTE Requires Lasso 9.1 or a late SVN patched version of Lasso 9.0 due to changes/fixes made to the date type
2011-08-31 JC First version
**/
define tzconvert(
date::date,
input_timezone::string = #date -> timezone,
output_timezone::string = 'GMT',
format::string = '%Q %T',
convert::boolean = false
) => {
local(_date = date(#date -> format('%q')))
#_date -> timezone = #input_timezone
local(zoneoffin = #_date -> ascopy -> zoneoffset)
#zoneoffin += #_date -> ascopy -> dstoffset
#_date -> timezone = #output_timezone
local(zoneoffout = #_date -> ascopy -> zoneoffset)
#zoneoffout += #_date -> ascopy -> dstoffset
#convert ? #_date -> add(-millisecond = (#zoneoffout - #zoneoffin))
#_date -> setformat(#format)
return #_date
}
define tzconvert(
date::date, // input date
-tz_in::string = #date -> timezone,
-tz_out::string = 'GMT',
-format::string = '%Q %T',
-convert::boolean = false
) => tzconvert(#date, #tz_in, #tz_out, #format, #convert)
?>