I’m just testing the new dateTimePicker item in Xojo, and can’t seem to find any way that I can do a calculation. There is nothing like .ToSeconds or .Timefrom1970 sort of thing.
How do you do that? Or is it possible.
Update: I figured out how to do it. I guess my fumble finger typing didn’t show the SecondsFrom1970.
You can calculate time differences in Xojo using the SecondsFrom1970 property of DateTimePicker.
Example:
Dim startTime As DateTime = DateTimePicker1.Value
Dim endTime As DateTime = DateTimePicker2.Value
Dim secondsDifference As Double = endTime.SecondsFrom1970 - startTime.SecondsFrom1970
Dim hoursDifference As Double = secondsDifference / 3600
This gives you the difference in seconds or hours.
SecondsFrom1970 is the simplest way to do time calculations in Xojo.
You’re not wrong in that DateInterval is a convenient way to do date math, and preferable in many situations, but it’s not the only way. Using SecondsSince1970 seems just as valid - these are all just different ways of representating the same concept, similar to inches vs. centimeters. It really depends on what the code is trying to accomplish.
Replying to slop probably doesn’t help - it may even give it legitimacy by appearing to be engagement. We really do need a way to flag AI garbage if we want to keep this forum useful. Admins?
There are a number of red flags before you get into the body of the post, such as creating an account just to necromance a 5 year old thread.
The advice is bad. There ARE wrong answers in software development, contrary to the belief of some.
6 years ago we did manipulate the TotalSeconds, but DateTime in API 2.0 was built intentionally to be immutable to help everyone reduce common mistakes. The promise to us developers was that using DateTime and TimeInterval would help us with international and zoning issues as well. Doing seconds math circumvents all of the benefits we were promised by the framework. Unless there’s a bug in the framework you need to work around, it’s bad advice.
Ais don’t think, text generation ones are fancy probability machines. The above isn’t good advice, it’s what we talked about 6 years ago with some property names switched around.
There’s a technique spam hives use that’s basically “mods are asleep, go go go”.
Thank you Tim, I didn’t see the two posts before Vikky Kaushal were years 2021. I thought the forum automatically close topic without answer for 2 years.