Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DOC: Thoroughly document datetime issues #2858

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 27, 2012

Conversation

certik
Copy link
Contributor

@certik certik commented Dec 27, 2012

After understanding the issues with datetime (see gh-568), I have documented my
understanding as comments in the code, so that the next time there are problems
with datetime on some platform, one can quickly figure out what is going on
from the code + comments.

After understanding the issues with datetime (see numpygh-568), I have documented my
understanding as comments in the code, so that the next time there are problems
with datetime on some platform, one can quickly figure out what is going on
from the code + comments.
@certik
Copy link
Contributor Author

certik commented Dec 27, 2012

@charris, @rgommers, @87 --- you all worked with datetime issues at one point or another. Would you please review my documentation in this PR? I want to make sure that my understanding is consistent with your understanding. See also my notes in the issue #568.

@certik
Copy link
Contributor Author

certik commented Dec 27, 2012

Note: I have removed the words "HACK" from the comments, because it is not a hack. In fact, I think it's the only way to make localtime() work with 32 bit time_t for years later than 2038. I think it works just fine and there is no issue. I have however carefully documented how it works.

@rgommers
Copy link
Member

This is clear, thanks for tracking down the issue.

These time functions are quite a mess. I guess there are platforms where 64-bit time functions aren't available? Otherwise always using 64-bit seems easier.

@charris
Copy link
Member

charris commented Dec 27, 2012

On Thu, Dec 27, 2012 at 2:14 PM, Ralf Gommers [email protected]:

This is clear, thanks for tracking down the issue.

These time functions are quite a mess. I guess there are platforms where
64-bit time functions aren't available? Otherwise always using 64-bit seems
easier.

On Linux, gcc time_t is a long, so 32 bits on 32 bit systems. Seems like an
unfortunate choice to me, but maybe they had their reasons. I don't know of
any 64 bit functions to replace the C library functions. Even Boost
datetime suffers from the 2038 problem and a bug filed on it has been open
for several years now.

Chuck

@certik
Copy link
Contributor Author

certik commented Dec 27, 2012

I think the fix is generally to use the same approach as numpy --- use the more sophisticated datastructure that can handle any date, and then only use localtime between 1970-2038. On Windows, even with 64 bits, it still can't handle dates before 1970, so one would need to use a workaround anyway.

So I'll merge this issue now.

@@ -34,8 +40,35 @@
/*
* Wraps `localtime` functionality for multiple platforms. This
* converts a time value to a time structure in the local timezone.
* If size(NPY_TIME_T) == 4, then years must be between 1970 and 2038. If
* size(NPY_TIME_T) == 8, then years must be later than 1970. If the years are
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

64 bit linux allow negative time, it seems it is windows where it is unsigned. That's not to say the comment is incorrect for the code ;)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I see the following text clarifies this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. If you know a better formulation, let me know.

@charris
Copy link
Member

charris commented Dec 27, 2012

Excellent notes, they describe the problem very clearly.

Multiline comments should begin with a blank line. This patch fixes it.
charris added a commit that referenced this pull request Dec 27, 2012
DOC: Thoroughly document datetime issues
@charris charris merged commit ec8236e into numpy:master Dec 27, 2012
@charris
Copy link
Member

charris commented Dec 27, 2012

Looks good, merged.

@certik certik deleted the document_datetime branch December 28, 2012 00:02
@certik
Copy link
Contributor Author

certik commented Dec 28, 2012

Thanks!

@certik certik mentioned this pull request Dec 28, 2012
@certik
Copy link
Contributor Author

certik commented Dec 28, 2012

Backported in #2861.

certik added a commit that referenced this pull request Dec 28, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants