While developing a calendar view I built an array of dates for the month starting with the 1st. I was also computing the day of the week in order to populate the calendar array. When I tested November, 2020, the 1st Monday ended up with the same date as Sunday. In further testing, I realized it is consistent in November of any year. The following code illustrates the problem in years 2020 to 2023.
I originally looped through all months but found no problems in any other months.
You will note in the log that the 1st monday Lg value is incremented properly by 864 ticks per day but it resolves to the same date as the previous Sunday.
I am on b4a version 10.2. Java version 8.
Sorry for the double letter vars (ii, jj..) I tested in my real program and didn't want to scrap on other vars.
Sorry I can't find how to copy the log so I could include it. Let me know how for next time.
Thanks, Cliff
Dim ii,jj,kk As Int
Dim lg As Long
Dim xx As String
Log ("Start November Date Check")
DateTime.DateFormat="yyyy/MM/dd"
For jj=2020 To 2023
xx=jj & "/" & "11/01"
Log (" ")
lg=DateTime.DateParse(xx)
For ii=1 To 10
xx=DateTime.Date(lg)
kk=xx.SubString2(8,10)
If kk<>ii Then
Log (ii & " " & xx & " " & DateTime.GetDayOfWeek(lg) & " " & lg & " Error in day")
Exit
Else
' ok
Log (ii & " " & xx & " " & DateTime.GetDayOfweek(lg) & " " & lg)
End If
lg=lg+DateTime.TicksPerDay
Next
Next
I originally looped through all months but found no problems in any other months.
You will note in the log that the 1st monday Lg value is incremented properly by 864 ticks per day but it resolves to the same date as the previous Sunday.
I am on b4a version 10.2. Java version 8.
Sorry for the double letter vars (ii, jj..) I tested in my real program and didn't want to scrap on other vars.
Sorry I can't find how to copy the log so I could include it. Let me know how for next time.
Thanks, Cliff
Dim ii,jj,kk As Int
Dim lg As Long
Dim xx As String
Log ("Start November Date Check")
DateTime.DateFormat="yyyy/MM/dd"
For jj=2020 To 2023
xx=jj & "/" & "11/01"
Log (" ")
lg=DateTime.DateParse(xx)
For ii=1 To 10
xx=DateTime.Date(lg)
kk=xx.SubString2(8,10)
If kk<>ii Then
Log (ii & " " & xx & " " & DateTime.GetDayOfWeek(lg) & " " & lg & " Error in day")
Exit
Else
' ok
Log (ii & " " & xx & " " & DateTime.GetDayOfweek(lg) & " " & lg)
End If
lg=lg+DateTime.TicksPerDay
Next
Next