@Offler This answer was not meant as a copy and paste ready to use solution. I included the struct to show how it worked. For a real example view the source code to the
hwclock
program.