I couldn't find the code in your post. You can run the following sequence to write into RTC register.
1. Set WEN=1 by sending WREN command
2. Write 0x02 to RTC register 0x00.
3. Set WEN=1 by sending WREN command
4. Write to RTC time registers 0x09-0x0B (Sec, Min, HR). This is called the base time.
5. Set WEN=1 by sending WREN command
6. Write 1 byte to RTC register 0x01.
7. Set WEN=1 by sending WREN command
8. Write 0x00 to RTC register 0x00.
9. Read and verify time reading from RTC register. It should read the correct time now.
Sorry, please ignore the previous post as it was with respect to SPI RTC part. Since you are using the I2C, you should follow the folowing sequence.
1. Write 0x02 to RTC register 0x00. - This will set the 'w' bit
2. Write 3 bytes to RTC registers 0x09-0x0B. (Sec, Min, HR) - This will set a new base time
3. Write 0x00 to RTC register 0x00. This will clear 'w' bit
4. Read time from RTC registers and verify. This should read now new time.
5. For calendar setting (dd, mm, yy century....) you can set the respcetive registers (0x0C - 0x0F, 0x01) accordingly.
Please let me know if this helps to resolve your query.