Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat should we do to prepare for 2038?
    primarykey
    data
    text
    <p>I would like to think that some of the software I'm writing today will be used in 30 years. But I am also aware that a lot of it is based upon the UNIX tradition of exposing time as the number of seconds since 1970.</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;time.h&gt; #include &lt;limits.h&gt; void print(time_t rt) { struct tm * t = gmtime(&amp;rt); puts(asctime(t)); } int main() { print(0); print(time(0)); print(LONG_MAX); print(LONG_MAX+1); } </code></pre> <p>Execution results in:</p> <ul> <li>Thu Jan 1 00:00:00 1970</li> <li>Sat Aug 30 18:37:08 2008</li> <li>Tue Jan 19 03:14:07 <strong>2038</strong></li> <li>Fri Dec 13 20:45:52 <strong>1901</strong></li> </ul> <blockquote> <blockquote> <p>The functions ctime(), gmtime(), and localtime() all take as an argument a time value representing the time in seconds since the Epoch (00:00:00 UTC, January 1, 1970; see time(3) ).</p> </blockquote> </blockquote> <p>I wonder if there is anything proactive to do in this area as a programmer, or are we to trust that all software systems (aka Operating Systems) will some how be magically upgraded in the future?</p> <p><strong>Update</strong> It would seem that indeed 64-bit systems are safe from this:</p> <pre><code>import java.util.*; class TimeTest { public static void main(String[] args) { print(0); print(System.currentTimeMillis()); print(Long.MAX_VALUE); print(Long.MAX_VALUE + 1); } static void print(long l) { System.out.println(new Date(l)); } } </code></pre> <ul> <li>Wed Dec 31 16:00:00 PST 1969</li> <li>Sat Aug 30 12:02:40 PDT 2008</li> <li>Sat Aug 16 23:12:55 PST <strong>292278994</strong></li> <li>Sun Dec 02 08:47:04 PST <strong>292269055</strong></li> </ul> <p>But what about the year 292278994?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload