Fixes handling of the GNU C Library default timezone value#601
Conversation
|
Hmmm... This is an untested branch and seems obviously right, but I'm not sure how this has never come up before. @lapointexavier Did this come up for you "in the wild", or did you figure it out from the docs? CI failure is fixed in #602, when that is merged you can rebase against master to get a passing CI run. |
|
It actually came out since we switched our dev environment to kubernetes. I imagine something's different in the environment as we were using vagrant before. This block of code started failing and I had to drop in a debugger to see what was going on. (code edited for simplicity) dateutil.tz.gettz() would return None, and realized that the environment variable was the following: |
|
Interesting, seems like just no one was hitting that branch before, which is interesting in itself. For your current situation, here's a workaround: LOCAL_TZ = dateutil.tz.tzlocal()
dt = dateutil.parser.parse('<some datetime>')
dt = dt.astimezone(LOCAL_TZ).replace(tzinfo=None)Since you throw away the time zone immediately anyway, it doesn't really matter if you get a |
|
@lapointexavier I merged #602, so if you want to rebase against master that will fix CI, then I can merge this one. |
|
ah great, thanks! |
The default can be `TZ=:/etc/localtime` (it may vary). See the documentation: https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
7389d30 to
de868a6
Compare
|
@pganssle Should be good to go 🚀 |
|
@lapointexavier Oh, one other thing (probably should add this to the PR template when I get a chance), can you add yourself to the |
|
Nice catch. |
|
@lapointexavier By the way, I masked those e-mail address domains because I hadn't asked permission from those authors to actually publish their e-mail address. If you want your e-mail address included, I can include it next time I make a change to |
|
@pganssle yeah I was a little ambivalent. I guess it wouldn't hurt anyway. Here it is: |
Description
I just found an edge case (I believe) that was not handled properly. It seems like the slice on the
TZenvironment variable value was incorrect, usingname[:-1]instead ofname[1:].I would end up with the following:
... instead of:
/etc/localtimeBackground
The default timezone value can be
TZ=:/etc/localtime. It may vary, but usually starts with:.Documentation: https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html