I’m playing around Xojo.Core.Date and its Timezone property. So I placed this in a button action to test some stuff out:
[code]Dim laTZ As New Xojo.Core.TimeZone(“PST”)
Dim laDate As New Xojo.Core.Date(Xojo.Core.Date.Now.Year, _
Xojo.Core.Date.Now.Month, _
Xojo.Core.Date.Now.Day, _
Xojo.Core.Date.Now.Hour, _
Xojo.Core.Date.Now.Minute, laTZ)
When I attempt to compile the above, I’m told that “there is more than one item with this name and it’s not clear to which this refers.” The entire final MsgBox line is highlighted.
I’m told "type “Xojo.Core.Date” has no member named “FormatStyles.”
My reading online only shows people using code of the first format above, but I can’t seem to get that to work. I’ve tried a bunch of other changes to try to get that to work, but all to no avail.
In my experience, with the way you are using msgbox as a statement, sometimes it pays to assign a function to a string variable on a previous line and on the next line make the message box display that string variable.
I note that in the language reference, message box syntax is expressed as a function msgbox("hello world") and returns a value to your calling code in desktop apps but not Web and Console apps.
[quote=414040:@Dave S]Could it be that you are passing TEXT to the msgbox where it is expecting a STRING?
never understood why this is or should be a distinction[/quote]
I’ve always found I could pass Text to MsgBox. But I also tried converting to String on a separate line and passing that String variable to MsgBox (as Eric suggested), and that yielded the same error message, highlighting the entire FormatStyles line.
[quote]Could it be that you are passing TEXT to the msgbox where it is expecting a STRING?
never understood why this is or should be a distinction[/quote]
ToText object provides access to a bunch of methods operating on text characters, which to support different languages may be encoded using more than one byte per character, which the programmer doesn’t have to worry about.
Thanks, Scott. I’m finding this Timezone thing getting confusing (and perhaps unreliable) and think I’ll just stick with GMTOffset values whenever this is practical. In my current app, this is very doable.
And I can safely assume that in the following code
Dim laTZ As New Xojo.Core.TimeZone("America/Los_Angeles")
Dim nyTZ As New Xojo.Core.TimeZone("America/New_York")
Dim nowDate As Xojo.Core.Date = Xojo.Core.Date.Now
Dim laDate As New Xojo.Core.Date(nowDate.SecondsFrom1970, laTZ)
Dim nyDate As New Xojo.Core.Date(nowDate.SecondsFrom1970, nyTZ)
not only will laDate and nyDate be 3 hours apart, they also will reflect whether or not Daylight Savings Time is active? That is, I can rely on Xojo to know if DST is active in this or that timezone and report the correct time accordingly?
Well, well. That is impressive. I’ve never strayed from Classic Date, and just the last 24 hours stated experimenting with the Xojo.Core.Date code to see how to use Timezones. Thanks, Scott.