Bug in ShortDate

Hello,

The following shows a problem with ShortDate. 

The code:
dim laDate as new date
print "Les dates: "
print " abbreviated: "+str(laDate.abbreviatedDate)
print " shortDate : "+str(laDate.shortDate)
print " longDate : "+str(laDate.longDate)
print " shortTime : "+str(laDate.shortTime)
print " longTime : "+str(laDate.longTime)

Le rsultat:
Les dates:
abbreviated: 30 04 2017
shortDate : 30/04/2015
longDate : Sunday 30 April 2017
shortTime : 11:27
longTime : 11:27:00

The date was correctly 30/04/2017. The year given by ShortDate is WRONG.
I use the last version of XOJO, 2017 release 1.1, on an iMac with OS X 10.10.5.

Cordially,
Daniel

The title should have been Bug in ShortDate

I don’t know where you found print in Xojo desktop… Unless you wrote to a file and omitted all the code before to render that possible. But I just did a global replace to system.debuglog, and here is the result :

dim laDate as new date system.debuglog "Les dates: " system.debuglog " abbreviated : "+laDate.abbreviatedDate system.debuglog " shortDate : "+laDate.shortDate system.debuglog " longDate : "+laDate.longDate system.debuglog " shortTime : "+laDate.shortTime system.debuglog " longTime : "+laDate.longTime

System Region set to French preferences.

Les dates: abbreviated : 30 Apr 2017 shortDate : 30/04/2017 longDate : Sunday, 30 April 2017 shortTime : 12:28 longTime : 12:28:55

Exactly the same result in a Console program where indeed, Print can be used.

iMac mid 2011, macOS Sierra 10.12.4, 2017R1.1.

I really wonder how you can get 2015 in there in only shortdate …

If you can reproduce the issue reliably, then it would be nice to post your project.

And you don’t need the Str(). All those dates are strings anyway.

XojoScript ?

Can’t be. Xojoscript doesn’t have dates.

[quote=328421:@Daniel Drijard]Hello,

The following shows a problem with ShortDate. 

The code:
dim laDate as new date
print "Les dates: "
print " abbreviated: "+str(laDate.abbreviatedDate)
print " shortDate : "+str(laDate.shortDate)
print " longDate : "+str(laDate.longDate)
print " shortTime : "+str(laDate.shortTime)
print " longTime : "+str(laDate.longTime)

Le résultat:
Les dates:
abbreviated: 30 04 2017
shortDate : 30/04/2015
longDate : Sunday 30 April 2017
shortTime : 11:27
longTime : 11:27:00

The date was correctly 30/04/2017. The year given by ShortDate is WRONG.
I use the last version of XOJO, 2017 release 1.1, on an iMac with OS X 10.10.5.

Cordially,
Daniel[/quote]
How about providing us with an actual project to look at, since the code you’ve written doesn’t run.

I ran the code as a console app in 2017 r1.1 and it works as expected, short date is 4/30/17 (here in the US).

Here, in Spain the output is correct (same format that in FranceI) 2017r1.1 / 10.12.4

Les dates:
abbreviated: 30 abr 2017
shortDate : 30/4/17
longDate : domingo, 30 de abril de 2017
shortTime : 22:24
longTime : 22:24:45

I got replies seeming to indicate that my code is the source of the poblem, not “ShortDate” itself. My code is pretty long. I shall extract a small piece around the culprit and study it further. I shall transmit my results, hopefully in a few days.

So the code you posted is not the actual code ?

Michel,
Yes, the code I posted is the right one but there are some 5000 other lines in the program which should be disconnected from the problem. My “print” command/routine could be the culprit but I must extract the few lines relevant (50 or so) to be clear.

As you can see without your famous “print” method everything is just fine. Chances are it is indeed there that something is wrong.

I checked Print, not Date :wink: or :(…

Question to Michel Bujardet:
I constructed a small program, TestingShortDate, which shows again the problem. It is of size 29 KB. How can I send it to you ?
Daniel

Put it in Dropbox, Google Drive, or Microsoft OneDrive and use the equivalent of “Share Public Link”

Tim,
I am probably too old fashioned. I have no such “DropBox, Google Drive”. About “Windows…” I have nothing either. I suppose that “Share Public Link” is related to the objects mentioned earlier … and having an equivalent is further not possible.

[quote=328996:@Daniel Drijard]Question to Michel Bujardet:
I constructed a small program, TestingShortDate, which shows again the problem. It is of size 29 KB. How can I send it to you ?
Daniel[/quote]

I PM you my email address

That said, have a look at dropbox.com Basically you subscribe for free to that service, and then it lets you upload files and if needed, share them as a download URL.

Such “cloud drive” is also very convenient to save data away from risks of all nature. I regularly save my programs sources that way, in addition to external drives.

I did get your project I am posting here for others.

I see nothing in there that could explain the bug posted in OP.

Have you tried what I posted above ?

dim laDate as new date system.debuglog "Les dates: " system.debuglog " abbreviated : "+laDate.abbreviatedDate system.debuglog " shortDate : "+laDate.shortDate system.debuglog " longDate : "+laDate.longDate system.debuglog " shortTime : "+laDate.shortTime system.debuglog " longTime : "+laDate.longTime

I see you are using a RealBasic format. Under which version do you get this strange bug ?

I get the correct dates from the project also.