Fixed day_of_week function as it could sometimes return negative values internally.
Merge branch 'day-of-week-issues' into PHP-5.5