Skip to content
schwern edited this page Jun 28, 2012 · 4 revisions

This project is in need of an experienced C programmer to apply C best practices and review the code

This project is in need of more cross platform testing

The goal of this project is to provide a drop-in replacement for POSIX [http://www.opengroup.org/onlinepubs/009695399/basedefs/time.h.html time.h] which will work on machines which have a 32-bit time_t, yet not suffer from the [https://secure.wikimedia.org/wikipedia/en/wiki/2038_bug 2038 bug]. This will allow C programmers to be 2038-safe without having to rewrite their software to a new interface. It does this while still using the system time zone database.

Many Unix time and date functions cannot calculate a date beyond Tuesday, January 19, 2038. This is known as the Year 2038 Problem and it effects most Unix and Macintosh computers currently in use.

Unlike the Y2K bug, it is by design and we know how to fix it. time_t, the data type which stores time on Unix, is normally only large enough to hold time up to 2038. Making it larger would solve the problem. Many 64 bit operating systems have done that, but that requires recompiling much of your software, so many have not. For example, most Macs run on a 64 bit processor but still use the smaller 32 bit time_t.

Our [http://code.google.com/p/y2038/wiki/TargetProjects first targets] are Perl, Ruby and Python.

The first goal was to replicate [http://www.opengroup.org/onlinepubs/009695399/functions/localtime.html localtime()] and [http://www.opengroup.org/onlinepubs/009695399/functions/gmtime.html gmtime()] in order to allow Perl to work around a system's 2038 limit. This has been accomplished and [http://perldoc.perl.org/perl5120delta.html#Y2038-compliance in Perl since 5.12.0].

The next goal is to complete all the POSIX functions and improve our compliance with the spec.

The y2038 project is funded in part by a [http://www.perlfoundation.org/make_localtime_and_gmtime_work_past_2038 grant] from [http://www.perlfoundation.org/ The Perl Foundation].

What works?

The following functions are implemented and well tested.

  • localtime64_r()
  • localtime64()
  • gmtime64_r()
  • gmtime64()
  • timegm64()
  • mktime64()
  • asctime64_r()
  • asctime64()
  • ctime64_r()
  • ctime64()

What platforms?

This complies with the POSIX standard for time.h and will work with any decent ANSI C89 compiler.

Want to help?

Please send a message to [http://groups.google.com/group/y2038-users y2038-users], or do a [http://code.google.com/p/y2038/source/browse/trunk/time64.c code review], or [http://github.com/schwern/y2038/issues/new post an issue], or try to fix [https://github.com/schwern/y2038/issues an existing issue] or try out the code on your machine and let us know how it works out.

Clone this wiki locally