Sponsored link Serve your customers, not your servers, with VERIO Linux VPS. Full-access test-drive here. |
Time representationTime representationPosted Sep 13, 2006 16:08 UTC (Wed) by rvfh (subscriber, #31018)In reply to: Time representation by HenrikH Parent article: What you should (and shouldn't) expect from 64-bit Linux (Linux.com)
In this case one can only code dates which are 68-odd years either side of 1 January 1970, i.e. 1902 to 2038. This does not even cover birth dates for many countries' population! No, really, applications need a lot more possibilities than the operating system does, so back to square one: the OS could have an unsigned number for its current epoch. Quoting David Schwartz
on the same kind of discussion:
(Log in to post comments)
Why is time_t not unsigned Posted Sep 13, 2006 16:29 UTC (Wed) by rvfh (subscriber, #31018) [Link] I found an answer to my own question, in case anybody is interested... If you start a system with time = 0 and local time is GMT-something (any place west of Greenwich: Brasilia (GMT-3), New York (Eastern time), ...), then you get time before 1 January 1970. Well, you don't if time_t is unsigned! You get time in 2107 instead :-(
Time representation Posted Sep 13, 2006 19:35 UTC (Wed) by HenrikH (guest, #31152) [Link] Who ever said that it was wise by the applications to use time_t ;-)
Anyways one reason that it is used is that time_t has excellent support in libc with conversion functions between localtime and UTC for current and historical dates. So one does not have to find another date library. Also since you get a time_t from the gettimeofday() systemcall one tend to use the very same variable in the application, it is not the the kernel is completely isolated into its own world.
Time representation Posted Sep 13, 2006 20:39 UTC (Wed) by dark (subscriber, #8483) [Link] the OS could have an unsigned number for its current epoch.Not anymore, it can't :) Too many applications rely on it being signed. (And if you don't mind breaking those, then why not move to 64 bits instead?) One reason they rely on it is that in addition to using time_t to represent dates, they subtract time_t values from each other to represent intervals.
For example: If time_t is unsigned, this condition will be true if time() is already past the deadline, thus causing an infinite loop. Well, not really infinite... just 68 years :)
|
Copyright © 2008, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds
Powered by Rackspace Managed Hosting.