DS3231 on power off

I am working on a simple digital watch and i am using DS3231 and atmega328, both have the same power source 3v button battery.

First when compiling i set the time in setup, relevant part of the code:

#include <RTClib.h>
RTC_DS3231 rtc;

void setup(){
  rtc.adjust(DateTime(2018, 7, 5, 15, 1, 50)); //year, month, day, hour, minute, second
}

After that i compile script again but this time i remove rtc.adjust line.
Idea behind this is if both RTC and atmega328 loose power that next time i turn on the watch i don’t need do modify time from DateTime(2018, 7, 5, 15, 1, 50) instead i would modify time from last time RTC had power (witch is more practical).

The problem is it isn’t working, it does keep time as long as the power is on RTC and everything works as expected when resetting the code it doesn’t set time back it just keeps counting from time before reset. But when i remove battery time restarted to 0 hours, 0 minutes, 0 seconds.

I know that DS3231 needs power source to count time.
My question is can it keep time (without counting) when power is off (example, changing battery) or does it lose memory of time completely when power is off.

Remove power from the DS3231 and all register contents are lost, becoming zeros when power is restored. The device has provisions for a backup battery (Vbat terminal) so it maintains operation using only 110ua of current from a 3 volt coin cell.

You need Vbat connected directly to the battery to maintain operation when the watch is off.

I already know this part:

WattsThat: The device has provisions for a backup battery (Vbat terminal) so it maintains operation using only 110ua of current from a 3 volt coin cell.

You need Vbat connected directly to the battery to maintain operation when the watch is off.

But this is what i wanted to know:

WattsThat: Remove power from the DS3231 and all register contents are lost, becoming zeros when power is restored.

Thanks for the info, i didn't know that all register contents are lost, becoming zeros when power is restored. Before i thought that RTC should keep counting time from the last state it was working before it lost power supply.

Only with a battery connected to Vbat.

I’m was incorrect saying a power loss results in all registers being reset to zero, the date defaults to 01/01/0001. Also note that the datasheet contains this caveat:

Unless otherwise specified, the registers’ state is not defined when power is first applied.

Details here: https://datasheets.maximintegrated.com/en/ds/DS3231.pdf

WattsThat: I’m was incorrect saying a power loss results in all registers being reset to zero, the date defaults to 01/01/0001.

It's the default value saved in DS3231 so when you remove power from Vbat then registers kind of move back to factory settings. So, you have to keep the power to your RTC module. You should use this RTC Library for Proteus. You can also check this Arduino Based Digital Clock, it will help you in this project.