FS#11814 - calendar.rock day of week is off-by-one

Attached to Project: Rockbox
Opened by Timothy Stotts (timotheus) - Sunday, 19 December 2010, 06:33 GMT
Last edited by Bertrik Sikken (bertrik) - Thursday, 12 April 2012, 19:44 GMT
Task Type Bugs
Category Plugins
Status Closed
Assigned To No-one
Operating System iPod 5G
Severity Low
Priority Normal
Reported Version Release 3.7.1
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


The calendar.rock application displays the day of week for year 2010 off-by-one. On my player (iPod Video 30GB), the calendar application shows date 2010-12-19 as Monday when it is actually Sunday.
This task depends upon

Closed by  Bertrik Sikken (bertrik)
Thursday, 12 April 2012, 19:44 GMT
Reason for closing:  Fixed
Additional comments about closing:  Should be fixed by 449dff4
Comment by Bertrik Sikken (bertrik) - Sunday, 19 December 2010, 11:32 GMT
I think that this can either be a bug in the RTC driver for the ipod video (the PCF50605) or in the calendar plugin.

Does this still happen when you update the time (e.g. change it back and forth by an hour)?
Comment by Hayden Pearce (St.) - Monday, 20 December 2010, 08:32 GMT
It's present on My Nanos and Colours, and Time and Date reports the correct time/ I guess it is a problem with the plugin.
Except it's off by two days here.
The date is displayed correctly, just not the day.

Comment by Luke (gaming4jc) - Saturday, 01 January 2011, 00:00 GMT
Confirming, except on my Ipod Nano 2nd gen it's actually off by two days. (Says Wednesday instead of Friday even though the date is correct). I would suggest a slight elevation in priority since many people (including some one I know) use the calendar for work purposes.
Comment by Nils Wallménius (nls) - Saturday, 08 January 2011, 19:33 GMT
the date and weekday is correct and matches between time & date and the calendar on my h300 and fuze and in a beast sim so i'd guess it's a target specific problem or something weird
Comment by Bertrik Sikken (bertrik) - Saturday, 08 January 2011, 20:55 GMT
Works fine on my sansa c200, e200, clipv1, clip+ which all use the as3514 rtc driver.

The ipod video, nano 1g (assuming Hayden was referring to the 1g ...), the color all use the pcf50605 rtc driver.
It's not entirely clear what rtc driver the nano2g uses ("RTC_NANO2G", great), but it seems to be a pcf5063x.
So indeed it seems there is some bug in the pcf506.. family of rtc drivers.

Does this still happen when you update the time (e.g. change it back and forth by an hour)?
Comment by Luke (gaming4jc) - Friday, 14 January 2011, 02:59 GMT
Messed around with it a bit and found the 'magic fix'. Since I dabbled a bit I can't swear this to be 100% accurate.
1. Enable Daylight savings time on original firmware.
2. Reboot to Rockbox
3. Move clock back one hour since it is ahead one hour too much.
3. Go to Calendar and the dates days were displayed correctly. (e.g. Thursday the 13th)

It defiantly has some sort of correlation with the clock.
Comment by Timothy Stotts (timotheus) - Friday, 14 January 2011, 19:00 GMT

I tried your solution. My daylight savings time was off, so I turned it on, adjusted the clock, and now my clock is adjusted for that. However, I get the same calendar behavior as before: the day of the week is one day ahead of what it should be.
Comment by Bertrik Sikken (bertrik) - Saturday, 17 March 2012, 18:33 GMT
I looked a bit deeper into this including forcing an incorrect weekday in a simulator, my conclusions:
* the weekday is independently stored in the RTC chip of the PCF50605, so it is indeed possible to get a weekday that is off but have an otherwise correct date
* even if the weekday is off in the RTC, the time&date screen shows the correct weekday (because it is recalculated in this screen)
* when setting the time in the time&date screen, a corrected weekday is set in the RTC

So, changing the time&date should fix the weekday setting (even if you don't actually change the date). Has anyone tried that? (PLEASE DO!)
Perhaps the OF has a different idea about how the weekday should be coded.
Comment by Clyde R. McGee (clyde_m) - Tuesday, 20 March 2012, 07:57 GMT
Just have checked this on my iPod Video 60 GB. It works.
Comment by Bertrik Sikken (bertrik) - Tuesday, 20 March 2012, 13:58 GMT
Perhaps a more permanent solution is to ignore the week-of-day value in the RTC and always recalculate it ourselves (we already have the function to do this), unless this gives some conflict with the original firmware.
I think this needs to be discussed with some other rockbox developers first (like the person who wrote the pcf50605 RTC driver).