I know I’m overthinking this one but how would I go about casting an old Date object to the new Xojo.Core.Date object?
I purchased a control (encrypted) that returns the selected date (old object) but date manipulation routines I have created use the new framework. Not sure how to get the returned date into a new Xojo.Core.Date.
I just tested this and I am also researching any built in functions to see if there is a more efficient way to accomplish this.
HTH. (I tied this to a button action to test quickly).
// GET OLD FRAMEWORK DATE
Dim d as New Date
Dim dString as String = d.SQLDateTime
// CONVERT TO NEW FRAMEWORK DATE
Dim dateValue As Text = dString.ToText
Dim myDate As Date = Date.FromText(dateValue)
MsgBox "New Framework Date: " + myDate.ToText
[quote=209136:@Scott Rich]I know I’m overthinking this one but how would I go about casting an old Date object to the new Xojo.Core.Date object?
You cant cast one to the other
You can convert one to / from the other but it involves code like Mike posted
I’m not sure where this came from, but this consistently brings back the wrong date for me. For example, if the date in the database is 1962-02-18 00:00:00 it likes to bring back 1962-02-17 00:00:00. Has anyone else experienced this?
I had a bug report from (other peoples) code that used the above snippet and found that the above snippet consistently brought back the wrong date. No big deal to move it to using the global Date object. This is a warning for others that might use it verbatim as the person who wrote this code did.
Which snippet ? The totalsecond one, or the constructor with year, month, day, hour, etc ?
Whichever one it seems pretty easy to verify after constructing the Xojo.Core.Date if it is in sync with Classic. Could it rather not be an issue with the conversion between totalsecond and secondsFrom1970 ?
Using TimeControl and DateControl (EinHugur Plugin), i try to get time and Date valueChanged
These values changes only inside valueChanged Event (Date and Time ctrl), i would like to get the values changed every where in the project.