The routines I use are part of this library:
http://tpsystools.sourceforge.net/
I'm pretty confident that I'm using it correctly, but I'm wondering if the times are a day out. Now it's the 22nd, mine is now showing tomorrow to be 2s longer than today. It's all much more complicated than you would believe, I have to convert from local to UTC and then to Julian days, and then I have to work out which day it's actually referring to when I convert it back.
As a kludge I could add a day to the days I'm comparing, but that's quite horrible without understanding why it's wrong.
If anyone wants to provide a better library, I'd be happy to use it.