Programming with Time Library

The RTC (real Time Clock) chips I have used, had a small amount of memory (50 bytes or so) that you can use to keep some critical values across power breaks. It is kept valid by the same battery that the clock uses.