Main Site Documentation

RealTimeClock.SetDateTime not working


#1

I have recently moved one of my projects over to the latest NETMF 4.3 using a Cerbuino Bee. I can no longer use RealTimeClock.SetDateTime

The real time clock is keeping time while on the backup battery but I can not change it.

I searched the forums for a fix and found some code that seemed to work. But it was using a hardcoded date value. When I changed this to work with a Date that I send to the board over the serial port, it does not work.

In debugging this, I found that RealTimeClock.SetDateTime only works when the year is an even value.

Using this code

        _NewDate = new DateTime(2016, 12, 24, 10, 20, 30);
        try
        {
            RealTimeClock.SetDateTime(_NewDate); 
            Utility.SetLocalTime(_NewDate);
        }
        catch
        {
        }

        DateTime DT2;
        DT2 = RealTimeClock.GetDateTime();
        Debug.Print(DT2.ToString());

It correctly sets the date when the year is set to 2014, 2016, or 2018, but does not work when the year is set to 2015 or 2017.

Anyone else seen this issue?

Shawn


#2

I seem to remember something about a Sunday bug. Try again tomorrow.