then I checked these settings:
and I modified them like this:
no errors:
Finally, I don’t understand what relevance can have the United States setting instead of Italy, in the date format YYYY-MM-DD.
why 1977-05-21 and 1977-05-23 work and 1977-05-22 does not work?
maybe someone in the Xojo team can focus on this topic?
thank you
Filed a bugreport?
no, I will do it soon.
first I was pleased to share here my new tests.
and my worries because all seems very strange to me.
Must be a metric vs. imperial date issue
Sorry could not resist this comment
Have you looked at s3 in the debugger to see exactly what bytes it contains, and compared each byte with an ASCII table?
Can you share the Language & Region settings that you used on Mac? I did test changing to Italy but was not able to reproduce.
Did you try to define a locale as additional fromString parameter? As you are using US notation for the string, that one possibly?
From Wiki i read that in italy the date format is using “/”
Ok when you define a locale xojo expects:
If you specify a locale, the dateValue text must be formatted to match the locale you specify. For example, specifying the locale as “en-US” would then require the format to be MM/DD/YYYY.
https://documentation.xojo.com/api/data_types/datetime.html#datetime-fromstring
So this may be a better solution?
I meant to define US locale instead of Nil.
Try this one:
Dim d As DateTime = DateTime.FromString(“22/05/1977”, Locale.Current, TimeZone.Current)
That .FromString(“1977-05-22”) does is it takes a SQLDate (or SQLDateTime)
If you provide the other parameters it expects an locale based date(time), must be set…
I tried on a Windows 10 1909 laptop, changed the Region to “Italia” and can’t reproduce the problem. This is a weird error.
@DerkJ I understand what you are proposing, but it would not explain that his code only fails for one specific date, this is really strange, isn’t it?
Yeah, report it and move on… I have no clue what’s happening inside the .FromString… only Xojo can tell you what’s going on… I do find this a scary bug since this could happen in any datetime…
from Xojo documentation (Datetime): “When no locale is specified, the dateValue parameter can be in either SQLDate (YYYY-MM-DD) or SQLDateTime (YYYY-MM-DD HH:MM:SS) formats.”
In the real scenario, I receive the dates from a database text field, in YYYY-MM-DD format.
I don’t think I need to specify anything else.
especially because I receive thousands of dates and the only error occurred with that date!
Preferred language: English
Region: Italy
You can argue over what you aant but it’s not gonna be fixed from the forum comments… i use this as well and i see possible problems in this. We handle millions of dates! Just one failing can be a major issue if you expect it to do what it has to do.
This is out of your hands. Perhaps create a method that parses the string and return a datetime yourself?
I will report to Xojo Inc.
as we said before.
I just wanted to update you with my latest tests.
thanks all for suggestions.
Xojo2020r1.2, macOS 10.14.6 can’t reproduce using Language: English and Region: Italy
It will be hard for Xojo to reproduce, I hope they can.
Try this.