xojo.core.dateInterval ignoring timeZone?

Is xojo.core.dateInterval supposed to ignore whether or not a timeZone is associated with a date object? Lets say I have a date object that I assigned a time to, but didn’t assign the timezone (I just hard-assigned the utc time). I have another date that is the system time (which is in cdt), but used the timezone property to create a date object with its corresponding utc time. When I using xojo.core.dateInterval to compare the two… I get a difference of 4 hours, even though the two date objects appears to be the same when I use:

… .toText(xojo.core.locale.raw, xojo.core.date.formatStyles.full, xojo.core.date.formatStyles.full)

I don’t know if I’m doing something wrong or not; however, this seems to be completely the case in my scenario. Just want some clarification, as there is no mention in the documentation that is does. Thanks!

The two Date constructors require a timezone. How did you not “assign a timezone”? Can you show some sample code?

I created one using:

dim myDateObject as xojo.core.date
myDateObject = xojo.core.date.fromText(“2015-05-05 15:15:15”)

That one didn’t need a timeZone associated. I may be doing it wrong… completely wrong, hahaha.

EDIT: Come to think of it, that one didn’t require a ‘new’ statement. Hmmmm… yeah, I think I’m overlooking something here.

I forgot about FromText. That gives you a date in the current time zone. This is my test code:

  Dim myDate As Xojo.Core.Date
  myDate = Xojo.Core.Date.FromText("2015-05-05 15:15:15")
  
  Dim testDate As New Xojo.Core.Date(2015, 5, 5, 15, 15, 15, Xojo.Core.TimeZone.Current)
  
  ' myDate is the same as testDate
  ' both have SecondsFrom1970 = 1430853315
  ' both have same current TimeZone (America/New_York)
  
  Dim interval As xojo.Core.DateInterval
  interval = testDate - myDate
  ' interval is all 0

[quote=214171:@Paul Lefebvre]I forgot about FromText. That gives you a date in the current time zone. This is my test code:

[code]
Dim myDate As Xojo.Core.Date
myDate = Xojo.Core.Date.FromText(“2015-05-05 15:15:15”)

Dim testDate As New Xojo.Core.Date(2015, 5, 5, 15, 15, 15, Xojo.Core.TimeZone.Current)

’ myDate is the same as testDate
’ both have SecondsFrom1970 = 1430853315
’ both have same current TimeZone (America/New_York)

Dim interval As xojo.Core.DateInterval
interval = testDate - myDate
’ interval is all 0
[/code][/quote]

Going back to the documentation (.fromText)…
“Converts a textual date to an actual date using the optional locale”
I completely overlooked that… so that was, in fact, the issue. Appreciate the help Paul. Works like a champ now with the appropriate changes…