Lerameur,

So, just some basic high-level things to understand when dealing with these RTC ICs.
The data in the RTC registers are in BCD format.
When you make changes to them, say the Hours register you should follow some specific steps.

Get the BCD Hours from the RTC
Save the value of 12/24 mode in your code
Save the value of the am/pm bit value in your code
Mask out the am/pm and 12/24 bits if required
Convert the BCD hours to Decimal hours
Change the Decimal Hours to the value you want
Convert the Decimal Hours to BCD Hours
Set the 12/24 Bit correctly in the New BCD Hours value
Set the am/pm Bit correctly in the New BCD Hours value
Write the new BCD Hours value to the RTC

Try not not intermix operations.
Change the Hour value or change the 12/24 mode, but not both in the same action.

When in 12hr mode, change the time the way you need to for that mode.
When in 24hr mode, change the time the way you need to for that mode.

Another suggestion is create yourself a table for hours in Excel or a text editor.
List all the hours in 12hr mode and also for 24hr mode.
Then for each hour record the byte (in binary) value for the RTC Hour register you would need for that time, making sure to set/clear the 12/24 mode and am/pm bits appropriately.
Looking at that kind of table may help you visualize what you need in your code to change time values to/from different values and when changing 12/24 modes.

Just some thoughts that I followed quite a while back to get a handle on using RTC ICs.

Regards,
TABSoft