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
Use ISO timestamp in diff.py #51831
Comments
make diff.py produce unified diffs with ISO 8601 timestamps Currently generated timestamps are difficult to separate from filename |
Using ISO format certainly makes sense, but it seems to me that after |
That's true. Is there any way to get current TZ offset in Python? I can't |
Look at time.timezone - # I'm in US Central time, so it's -6 from UTC
>>> import time
>>> tz = time.timezone
>>> tz
21600
>>> tz / 60 / 60
6 |
Thanks! Now the most elegant patch I could think out. |
Looks cleaner and works for me. One very minor comment: the spaces inside the parenthesis on the |
Pepeighfied and regenerated. Should be flawless now. |
I think this is incorrect during daylight savings time: This should do it: |
New version detects DST using time.daylight flag. utcoffset = -(time.altzone if time.daylight else time.timezone) // 60 |
Using time.daylight is incorrect. time.daylight specifies the number of hours that the daylight offset is, not a flag to specify whether or not daylight savings time is in effect. Steven's suggestion of using time.localtime().tm_isdst seems to be the better route. |
Brian, documentation says quite the opposite. time.daylight |
The documentation could use some work. It means that if the timezone does use a daylight savings time period, time.daylight specifies the amount of the offset. In my timezone this value is 1. However, time.localtime().is_dst is currently 0, because we are not on savings time. For that reason, using time.daylight in your patch gives an incorrect result for me. |
http://msdn.microsoft.com/en-us/library/2t504ch6%28VS.80%29.aspx has some info for how this is implemented on Windows, and I get the same results on my Mac. On Linux an AttributeError is raised time.struct_time not having an attribute is_dst, and time.daylight matches the other two platforms. |
Whoops, nevermind the Linux comment on that last one. My typo there caused the exception. The result there is the same as the other platforms. |
So, is that right that even if time.daylight specifies the offset, this doesn't mean that this offset is active? MS documentation you referenced is unclear: "The _get_daylight function retrieves the number of hours in daylight saving time as an integer. If daylight saving time is in effect, the default offset is one hour." From this description it is easy to assume that if DST is not in effect then default offset would be 0. |
You are right. import time print time.asctime() Tue Feb 09 10:31:47 2010 Sun May 09 10:33:20 2010 There is already an issue bpo-7229 to correct the docs. I'll adjust my patch accordingly. Thanks for collaboration. |
Finally! (I really hope so) |
This seems like a new feature to me so I'm removing 2.6 from the list. My browser won't let me remove Python 3.1. |
I use this tool in instructions how to generate patches on windows, so I am interested to see this fix in the version, that users will likely to use for next couple of years, but I'd be happy to see this committed in any branch. If it is going to be committed in alpha only them I'd like to propose to change default diff format to unicode as well. Please, also review http://bugs.python.org/issue7585 that contains more important API change that also prevents diff.py from generating correct patches. |
|
I am sorry - too much windows to reply. This must be *unified*, of course. |
Ok. Let's commit it at least to 2.7 - I'll create a separate issue for discussion of unified diff format later. |
So, what about 2.7 ? |
2.7 is now frozen as far as new features go. It's still good for 3.2. I think this is ready to go, so I'll probably commit it later in the day. |
I still do not understand your policy - it is a tool, it is not a part of standard library. |
Adding Alexander as ISTM he may be interested to read the time discussion. |
The latest patch will produce wrong results if the file was last modified before timezone rules changed in your location. See bpo-1647654. |
New changeset ec95b94ea831 by Alexander Belopolsky in branch 'default': |
Thanks. I am glad OS TZ support finally issue took off. =) |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: