Date is feaking me out

Hi all,

got the same in RS2012 R2 and Xojo

I have a textfield with mask ####-##-## into which I enter a SQLdate.

if Len( me.Text) = 10 and me.Text <> kSQLdateFormat then
ParseSQLdate( me.text, Date )
end if

I enter 1111-11-11

In the debugger I can see that

  • the SQLdate is 1111-11-11

  • HOWEVER the date is the 4th of Nov 1111, not the 11th.

screenshot:

https://dl.dropbox.com/u/992591/REALbasic/Mailing%20List/SQLdate.png

movie:

https://dl.dropbox.com/u/992591/REALbasic/Mailing%20List/SQLdate.mp4

Sample project at

https://dl.dropbox.com/u/992591/REALbasic/Mailing%20List/SQLdate%20bug.rbp.zip

would appreciate if someone can run it and tell me if they see the same.

The long date will be displayed in the helptag after a valid SQLdate has been entered.

Anyone got an idea what is going on?

Thanks

Markus

P.S. Also posted this on the newsgroup (without referring to Xojo of course)

P.P.S.

I parse the date like this:

Private Sub ParseSQLdate(Text as String, ByRef ParsedDate as date)
// Text = YYYY-MM-DD

dim YYYY as integer
dim MM as integer
dim DD as integer

dim d as new date

YYYY = Val( Left( Text, 4 ) )
MM = Val( Mid( Text, 6, 2 ) )
DD = Val( Right( Text, 2 ) )

// if you set a date to the 31st of Feb then date changes it to the last day of Feb + the overhang of dates = 2nd or 3rd of March depending on jumpyear or not

// set d to the values entered

d.Year = YYYY
d.Month = MM
d.Day = DD

// if it is a valid SQLdate then nothing has changed

if d.Day = DD and d.Month = MM and d.Year = YYYY then

IsValidSQLdate = True

ParsedDate = d

else

IsValidSQLdate = False

end if

End Sub

Are you sure that those dates are supported by the date class?
From the LR:

I’m not sure how the date “1111-11-11” does fit into this…

Cheers,

Tom

Sorry - that might be it.

[quote=2368:@Markus Winter]Hi all,

if  Len( me.Text) = 10 and me.Text <> kSQLdateFormat then

[/quote]

This line doesn’t seem to make sense to me. What is the value of kSQLDateFormat?

Thanks Michael, but Thomas sorted me out. Not a bug, just a limitation (for which I now have to find a workaround).

kSQLDateFormat = “YYYY-MM-DD”

and is shown in grey in the textfield until you start typing a value.

Btw TotalSeconds is a double, so dates BEFORE 1.1.1904 can be represented by negative numbers.

The problem is actually the switch from Julian to Gregorian calendar in 1582

Entering 1582-11-11 gives the right long date (11th of Nov)

Entering 1581-11-11 gives the wrong long date (1st of Nov)

Would be nice if this bug could be fixed before Xojo is released so that we can use historical dates.

[quote=2387:@Markus Winter]Thanks Michael, but Thomas sorted me out. Not a bug, just a limitation (for which I now have to find a workaround).

kSQLDateFormat = “YYYY-MM-DD”

and is shown in grey in the textfield until you start typing a value.[/quote]

Ahh, that makes sense. I thought perhaps you were trying to use it like a regex to see if the data was entered in the right format or somesuch. Nevermind.

Out of range dates should raise an exception to avoid worst processing errors.