I'm using an Arduino and DS1307 for creating RTC but my code has some issue
Lets start with the order of the registers:

seconds  -- bit 7 is clock start/stop bit, 0 = enabled
minutes
hours    -- bit 6 is selector 12/24 hour, 
         -- when in 12 hour, bit 5 is am/pm, 1=pm 
         -- When in 24 hour, bit 5 indicates in hour 20...23
day      -- week day 1...7
date     -- day of month 1...31 
         -- where the most significant nibble can contain the values
         -- 0, 1, 2, 3
         -- where the least significant nibble can contain the values
         -- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
month    -- 0x1x indicates in upper 10 months
year
control
&lt;other ram&gt;


When writing these registers, the prior time is transferred to a background/image of the main registers.

Of key importance is the 'ack' bit, which is 'echoed' at the end of each byte transferred.  Here are the details:

DS13077 of 12Acknowledge: Each  receiving  device,  when  addressed,  is  obliged  to  generate  an  acknowledge  after  the reception  of  each  byte.    The  master  device  must  generate  an  extra  clock  pulse  which  is  associated  with this acknowledge bit.A device that acknowledges must pull down the SDA line during the acknowledge clock pulse in such away that the SDA line is stable LOW during the HIGH period of the acknowledge related clock pulse.  Of course, setup and hold times must be taken into account.  A master must signal an end of data to the slave by not generating an acknowledge bit on the last byte that has been clocked out of the slave.  In this case,the slave must leave the data line HIGH to enable the master to generate the STOP condition

so the first problem I see is the code sequence does not match the register sequence.  This is an error.

the second problem I see is the ACK bit is being set to the wrong value