I’m talking about this Issue: https://tracker.xojo.com/xojoinc/xojo/-/issues/71555
There are some parts of the world that Daylight time changes at midnight so no DateTime with 00:00:00, this may be the case for OP (we need to know the locale).
Is like trying to do this in the USA (well for all parts that the DST starts in March 10, 2024):
Var bDate As DateTime
bDate = DateTime.FromString("2024-03-10 02:00")
What timezone/region are you using?
According to: Daylight Saving Time Around the World 1979
there are 4 places that changed the clock during 1979-05-27 and all from 00:00 to 01:00 so your code will report an error there by not putting a time to the .FromString.
Precisely, I asked whether we are allowed to consider that 1:59 and 2:00 exist, 2:01 up to 3:00 don’t, and 3:01 exists, instead of saying 1:59 exists, 2:00 up to 2:59 don’t and 3:00 exists. It may sound a “silly” question, but I like to explore beyond our habits.
Well, I guess it’s defined strictly.
I only know that for Xojo 2:00 up to 2:59 (including seconds, my guess not tested) doesn’t exist (for USA clock forward day).
When I used Tivo, the guide didn’t show 2 am shows, so I had to program at 3:00 am. Shows of 2 hrs that started at 1:00 ended at 4:00.
I have never been awake when the clock forward happens, but I guess the phones will show 1:59 then 3:00 instead of 2:00.
And for the clock back we have double 2:00 up to 2:59 and not easy way for DateTime.FromString (using SQLDateTime) to set it to the first or the second 2:xx
hi back , traveling so i will be able to test in few days , the issue and the problem here is that Date should not be affected by time or else keep separate the date and the datetime format as in my case i get a birth date in the sql format and while i understand that when you do input the data as new , but when you get it , the first rule of data processing is not to alter the data in any way , now you are asking to put 03:00 and other tests while for the sake of testing i will do but i will not alter data just that because Xojo does not know how to handle a date .
it’s like i’m born in eu but because i input the data in US i was born one day earlier or late . those should be as they come and specially for dates not to change them based of GMT in some cases .
I convert all dates that I receive, into SecondsSince1970. That is then what I store in an SQLite database.The date will have a timestamp and a timezone too, so it’s not ambiguous. The trouble with your 2024-02-02 17:02:30 format is that it has no timezone and is hence completely ambiguous.
My timestamps then convert nicely back to a human readable form, with that form chosen by the user.
I understand your problem. We are just asking more information/tests to see if the problem is what Xojo already have on Issues (see above for case numbers).
In Xojo DateTime, even if you don’t define the hour, has an hour component. The problem is that if the hour component doesn’t exist Xojo shows the error you see.
Maybe Xojo can fix the problem or maybe they can add something like a DateTimeOnlyDate feature for cases that handling the hour could cause problems.
Exactly. It’s even outlined by the name of the class: DateTime.
I’d like to point out the obvious: even outside of programming, in real life, there are invalid dates. For example, 29th of February 2023, 35th of June 2023, or, in countries with daylight saving time, 24th of March 2024 at 2:30 (at this day, since the clock jumps from 2:00 to 3:00, there’s no 2:30).
These dates are invalid in real life so it’s expected that the computer won’t understand them. What DateTime would you expect to get if you pass “2023-02-29” (even without talking about the time part)?
Thank you for this, I remember when I used Date instead of DateTime that Date is forgiving about invalid input. I did a test and maybe OP may want to try to use Date instead of DateTime until Xojo either a) changes DateTime in some way (to at least work with invalid dates in the range of DST) or b) adds DateTimeOnlyDate option.
This works with Date:
var onlydate as new date
onlydate.SQLDate = "2024-02-30"
as this year February has 29 days the result for Date is:
March 1, 2024
I understand Date is deprecated buy I hope Xojo does not remove it in the future.