But how do I know if its AM or PM? I think the hours are 0-23. In which case it should give me 14:49:25.
to find out Also, will this algorithm take the leap seconds into account?
It will not. I'd suggest you to make sure if those seconds are important for your project, before you dig any deeper with them. I am concerned about the performance issues in the real time project.
You do not need to compute the offset every time you do conversion, it's not going to change
Compute it once, and keep the offset as a static member in your class. All arithmetic on constants will be done at compile time. Other than that the conversion takes just 2 additions and 2 multiplications.
[ August 10, 2004: Message edited by: Dmitry Melnik ]