I ran across an issue with Xojo.Core.Date that I talked about on the forums https://forum.xojo.com/18549-xojo-core-date-question.
The issue is that the new Date class does not have SQLDateTime. Well, technically it does with a generic ToText function. However, there is no way to get just the SQLDate portion without having to write your own method.
The ToText method has a LOT of power to do and it is considerably more powerful than the old Date class. The ability to work with Locale is very cool and should simplify some things. However, I have some issues with the ‘replacement’ for SQLDateTime.
First, SQLDateTime is very explicit in what it does. ToText (with no parameters) doesn’t tell me jack and the fact that I missed it in the documentation tells me the name absolutely 100% fails the ‘name explicitly tells you what it does’ test.
Second, there’s no option to just get the Date in SQL format. Sure, you can create your own method to get that but that’s one more thing to create, test, and maintain. There are times when you need just the SQLdate portion. It doesn’t matter why we need it – we need it.
The new Date class is full of wonderful things. However, removing functionality that many of us use every day should be avoided. I think this is one of those times where the Xojo engineers got too clever in the new framework. I’d much rather have the SQLDateTime and SQLDate methods back. They are much more explicit than ToText. If you agree, you can sign on to <feedback://showreport?report_id=37521>
Of course, like with the Numeric.FromText methods, I’m willing to be convinced that the Date.ToText method to get SQLDateTime is better. What say you?
Later I realized that we could accomplish everything by adding the SQL option to the DateFormat and Locale enumerations. Then the code would be something like this:
dim d as Xojo.Core.Date = Xojo.Core.Date.Now
dim t as text = d.ToText(Locale.None, Date.FormatStyles.SQL, Date.FormatStyles.SQL)
That would solve all of the issues, no? They get to keep ToText and we get the ability to format the date in whatever form we want. Then there is no ToText without Parameters.