I came to the conclusion that I was over engineering the problem. The PIC will be getting a POSIX Time stamp from the Server every 24hours or less and every so often it has to send data back with a POSIX time stamp. All I need to do is save the POSIX Time Stamp and increment it with an interrupt from the RTC every second. That solves the immediate requirement and works fine. I also found this code https://github.com/adafruit/RTClib courtesy of adafruit and the Arduino Community. I will pull it into my ChipKit UNO 32 and see what changes are required to make PIC32 Library out of it. I particularly like the BCD Functions, they probably only work on 2 Digit BCD but they make my long winded functions look silly: static uint8_t bcd2bin (uint8_t val) { return val - 6 * (val >> 4); } static uint8_t bin2bcd (uint8_t val) { return val + 6 * (val / 10); } Cheers Chris On 17 February 2012 15:49, Matt Bennett wrote: > On Fri, February 17, 2012 4:04 am, Chris Roper wrote: > > Thanks Alan, > > > > I had found that after posting and am busy digesting it. > > I think I see now how they convert to UNIX Time and handle the Leap Yea= r, > > now I need to try and work it back words, add in the BCD conversions a= nd > > take out the DST portion (we work only with UST/GMT for time stamps). > > > > I also note my error in the Epoch being 1979 I see now it is 1970 did I > > confuse it with the GPS Time? > > With all the software based clocks I have written over the years, alway= s > > in > > BCD, this is the first time I have tried to interact with networks. I > > didn't realise there were so many conflicting time formats out there. > > Not quite conflicting- just different definitions- which has resulted in > the recent discussions to eliminate the leap-second: > > http://www.bbc.co.uk/news/science-environment-16597191 > > Clocks have been made way more accurate than the rotation of the Earth, s= o > they need to be periodically adjusted. I don't think we can predict the > needs for the leap-seconds more than a year or so in advance, so if you > want to keep accurate time-of-day, using POSIX time requires a look-up > table, and may not be accurate with data more than a year or two old. > > If you're looking for relative time, POSIX or NTP time works great, > however, if you're looking for time-of-day, GPS time can be more useful. > > Matt > > Matt Bennett > Just outside of Austin, TX > 30.51,-97.91 > > The views I express are my own, not that of my employer, a large > multinational corporation that you are familiar with. > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .