This is basically the arduino.cc sample turned into a library for easier reusability. It's not perfect but it does the job. void clockWrite(byte year, byte month, byte day, byte wday, byte hours, byte ...
The original code was found at https://playground.arduino.cc/Main/DS1302/ and written by a arduino.cc user called Krodal. I refactored the code to be a C++ class for ...