RealTimeClock.SetDateTime() does not work for 2017-01-01 in G30 and G80

Hi. For some reason RealTimeClock.SetDateTime() is not working when I try to set the date to 2017-01-01. It works fine for other dates, such as 2017-01-02, 2016-01-01 and today. The problem occurs in G30 and G80.

Here is the program and debug output for my G80 test:

    public class Program
    {

        public static DateTime DT;    

        public static void Main()
        {
            DT = new DateTime(2017,3,11,17,30,0);
            RealTimeClock.SetDateTime(DT);
            Debug.Print("\n\rToday: DateTime(2017,3,11,17,30,0) (works fine) => " + RealTimeClock.GetDateTime().ToString("yyyy-MM-dd HH:mm:ss"));

            DT = new DateTime(2017,1,1,17,30,0);
            RealTimeClock.SetDateTime(DT);
            Debug.Print("\n\rJanuary first 2017: DateTime(2017,1,1,17,30,0) (Does not change !!!) => " + RealTimeClock.GetDateTime().ToString("yyyy-MM-dd HH:mm:ss"));

            DT = new DateTime(2017,1,2,17,30,0);
            RealTimeClock.SetDateTime(DT);
            Debug.Print("\n\rJanuary second 2017: DateTime(2017,1,2,17,30,0) (works fine) => " + RealTimeClock.GetDateTime().ToString("yyyy-MM-dd HH:mm:ss"));

            DT = new DateTime(2017,1,1,17,30,00);
            RealTimeClock.SetDateTime(DT);
            Debug.Print("\n\rTrying Jan first 2017 again: DateTime(2017,1,1,17,30,00) (Fails again !!!) => " + RealTimeClock.GetDateTime().ToString("yyyy-MM-dd HH:mm:ss"));
            
            DT = new DateTime(2016,1,1,17,30,00);
            RealTimeClock.SetDateTime(DT);
            Debug.Print("\n\rJanuary first 2016: DateTime(2016,1,1,17,30,00)  (works fine) => " + RealTimeClock.GetDateTime().ToString("yyyy-MM-dd HH:mm:ss"));
        }
    }

The thread '<No Name>' (0x2) has exited with code 0 (0x0).


Today: DateTime(2017,3,11,17,30,0) (works fine) => 2017-03-11 17:30:00


January first 2017: DateTime(2017,1,1,17,30,0) (Does not change !!!) => 2017-03-11 17:30:00


January second 2017: DateTime(2017,1,2,17,30,0) (works fine) => 2017-01-02 17:30:00


Trying Jan first 2017 again: DateTime(2017,1,1,17,30,00) (Fails again !!!) => 2017-01-02 17:30:00


January first 2016: DateTime(2016,1,1,17,30,00)  (works fine) => 2016-01-01 17:30:00

Any ideas?

I believe there is a known issue when setting the clock to a Sunday.

Thanks a lot Mike !!. I tried setting tomorrow’s date and it didn’t work either. I’ll search SetDateTime for sundays to see if I find a workaround.