Contributing Advent 9: Day of the week
This is another one in the Date/Time extension series. Bugs #63391 and #61599 both deal with PHP getting the Day of Week wrong in years before 1600. Technically I did not write the patch for this contribution, but I did add tests, verified it and merged it to all the four branches (PHP 5.4, 5.5, 5.6 and master).
However, it does seem that I introduced the bug in the first place. When writing the new date/time support about 7 years ago I was looking for an algorithm that would tell me the day of the week for any given (Gregorian calendar) date. Wikipedia has quite a good article on it. The article outlines the calculation of the century number. For the Gregorian calendar, that's quite straight forwards: 6 - (j % 4) * 2. For the Julian calendar it's not very difficult either. Although PHP uses the proleptic Gregorian calendar that I wrote about before, I mistakenly had used a formula that combined the Julian and Gregorian calendar calculations. This then resulted in wrong calculations before the year 1600. This is now corrected and ready for inclusion into PHP 5.4.24, 5.5.7, and later versions.
Life Line
Pink Sky at Sunset
I took this photo over the Christmas period in the Dutch city of Breda.
I walked 8.5km in 1h25m28s
I walked 8.1km in 1h21m10s
I walked 0.8km in 9m03s
I walked 4.8km in 50m12s
Went for a 20k walk through Bushy Park, along the Thames, and through Richmond Park and Wimbledon Common. It was a bit nippy!
I hiked 19.3km in 3h52m02s
Updated a pub
I walked 4.6km in 44m50s
I walked 4.9km in 47m58s
Update Westbourne Green area, now that it is open
I walked 11.9km in 2h3m03s
I walked 9.8km in 1h47m38s
I walked 10.2km in 1h34m25s
Whoop! FOSDEM travel and hotel booked. See you in Brussels at the end of January?
I walked 10.6km in 1h48m23s
I walked 3.0km in 33m38s
I walked 0.6km in 11m26s
I walked 6.5km in 1h17m46s
Updated a cafe
Updated a museum
I walked 1.1km in 12m41s
Updated a bench and a waste_basket
Updated a bench
Updated a bench



Shortlink
This article has a short URL available: https://drck.me/adv1309-af1