Here’s the code in the action even of a webbutton:
using xojo.Core
Dim d As Date = date.now // now in local time
// create two different time zones
Dim tz1 As New TimeZone(0) // GMT time zone
Dim tz2 As New TimeZone(-7200) // other time zone
// translate d into three time zones
Dim d1 As New Date(d.SecondsFrom1970, tz1)
Dim d2 As New Date(d.SecondsFrom1970, tz2)
Dim d3 As New Date(d.SecondsFrom1970, TimeZone.Current)
// print/show d in three different time zones.
MsgBox d1.ToText(Locale.Current, Date.FormatStyles.Short, Date.FormatStyles.Full)+EndOfLine+_
d2.ToText(Locale.Current, Date.FormatStyles.Short, Date.FormatStyles.Full)+EndOfLine+_
d3.ToText(Locale.Current, Date.FormatStyles.Short, Date.FormatStyles.Full)
Here is the output:
2/14/16, 3:48:22 AM GMT
2/14/16, 3:48:22 AM GMT
2/13/16, 8:48:22 PM Mountain Standard Time
The question: Why is the second line of output not expressed in a different time zone, and how do I get that to happen?
Works as expected for me when just running it from the 2015r4.1 IDE on OS X.
Interesting. I am using 2015r3.1 on Windows.
I will have to try 4.1 in the morning.
Anyone know if this is a known issue on 3.1?
Nope - I downloaded 2015r4.1 and executed the code below, with exactly the same result as with 3.1. The second line of output did not reflect the time zone tz2.
Any other help or insights on why this isn’t working?
Corrected post:
[quote=247087:@Mark Pastor]Nope - I downloaded 2015r4.1 and executed the code above, with exactly the same result as with 3.1. The second line of output did not reflect the time zone tz2.
Any other help or insights on why this isn’t working?[/quote]
Looks like there were xojo.core.date issues on Windows that were supposed to have been fixed last year. See <https://xojo.com/issue/37413>. Perhaps It wasn’t completely fixed or something new broke down the line.
It wasn’t clear to me that is the same issue (I just may not be reading it clearly), so I submitted a new case (I couldn’t find another related case in the feedback system).
42547 - Can not convert Xojo.Core.Date from one time zone to another on Windows 8.1
<https://xojo.com/issue/42547>