3 ms·
Agreed. There are good time/date libraries out there, including the functions in the Linux/GNU C runtime library. Trying to do this yourself is just asking for
by pmjordan 18y ago
Agreed. There are good time/date libraries out there, including the functions in the Linux/GNU C runtime library. Trying to do this yourself is just asking for unnecessary pain: the library functions handle all the quirks for you, from weekday/d/m/y h/m/s.ms.µs.ns <-> internal representation conversions to time zones, leap years, leap seconds, etc.
This is a solved problem. Use the existing solutions.
And if for some reason you need absolute control and the built-in functions just can't fulfill your obscure needs, using doubles doesn't seem like a particularly appealing solution at all, as you'll still end up with precision issues on non-integers, except they're harder to control because they will vary. If there's something the built-in functions can't do for you (I doubt it!) I suggest reading up on the internal representation those functions use, and see if you can build on it.