Solved

The 2038 bug

Posted on 2008-06-18
4
296 Views
Last Modified: 2010-04-15
My curiosity recently brought me to analyse what is the exact nature of the 2038 date problem.

Well as you all probably know, it comes from the limitation in the C standard library type 'time_t' which is usually defined as a 32 bits signed integer.

The time_t type is defined by the C standard to contain "the number of seconds elapsed since January 1, 1970, 00:00:00". The C documentation says it can contain dates up to January 18, 2038, 19:14:07.

But when I calculate the number of seconds a 32 bits signed integer can contain, I come to the number 2147483647, which is 24855 days, 3 hours, 14 minutes and 7 seconds. Adding this value to January 1, 1970, 00:00:00 gives the following date: January 19, 2038, 03:14:07

So how can you explain the difference between the C documentation date and the calculated date ?
0
Comment
Question by:stsanz
  • 2
4 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 21815581
Are you sure you included all leap years correctly in your calculation?
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 21815590
>> The C documentation says it can contain dates up to January 18, 2038, 19:14:07.

What timezone was that documentation for ?
0
 
LVL 53

Accepted Solution

by:
Infinity08 earned 125 total points
ID: 21815662
>> January 19, 2038, 03:14:07

That's the highest UTC date/time that can be represented by a signed 32bit time_t.

>> January 18, 2038, 19:14:07

That would thus be the highest date/time in UTC-8.
0
 
LVL 6

Author Comment

by:stsanz
ID: 21815674
Well I found all the explanations here :
http://en.wikipedia.org/wiki/Year_2038_problem

Thanks for your comments
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now