Lasso Soft Inc. > Home

[tzconvert]

Linktzconvert
AuthorJolle Carlestam
CategoryDate
Version9.x
LicensePublic Domain
Posted31 Aug 2011
Updated31 Aug 2011
More by this author...

Description

Method to set datetime values to specific timezones. Can also convert datetime values from the input timezone to the output.

NOTE Requires Lasso 9.1 or a late SVN patched version of Lasso 9.0 due to changes/fixes made to the date type

Sample Usage

tzconvert(date, -tz_out = 'Australia/Sydney')
'
' tzconvert(date_localtogmt(date),-tz_in = 'GMT', -tz_out = 'Australia/Sydney', -convert) '
' tzconvert(date, -tz_out = 'Australia/Sydney', -format = '%Q %T V', -convert) '
' tzconvert(date('2011-12-13 ' + date -> time), -format = '%Q %T V', -tz_out = 'Australia/Sydney', -convert) '
' tzconvert(date('2011-12-13 ' + date -> time), -format = '%-d %b %Y %H:%M:%S V', -tz_out = 'Australia/Brisbane', -convert) '
' tzconvert(date('2011-12-13 ' + date -> time), -format = '%-d %b %Y %H:%M:%S V', -tz_out = 'Australia/Darwin', -convert)

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.

 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)

?>

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