| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
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. |
Sorry, something went wrong.
|
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) LOCAL_TZ = dateutil.tz.gettz()
dt = dateutil.parser.parse('<some datetime>')
dt = dt.astimezone(LOCAL_TZ).replace(tzinfo=None)
dateutil.tz.gettz() would return None, and realized that the environment variable was the following: echo $TZ :/etc/localtime |
Sorry, something went wrong.
|
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 tzfile or tz.tzlocal. |
Sorry, something went wrong.
|
@lapointexavier I merged #602, so if you want to rebase against master that will fix CI, then I can merge this one. |
Sorry, something went wrong.
|
ah great, thanks! |
Sorry, something went wrong.
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
|
@pganssle Should be good to go 🚀 |
Sorry, something went wrong.
|
@lapointexavier Oh, one other thing (probably should add this to the PR template when I get a chance), can you add yourself to the AUTHORS.md file? Goes in alphabetical order by first name. Put a D next to your name to indicate that your contributions have always been dual-licensed Apache/BSD. You can use any name you want, all fields are optional. |
Sorry, something went wrong.
|
Nice catch. |
Sorry, something went wrong.
|
@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 AUTHORS.MD. I assume you realize this and didn't want your e-mail included, but I thought I'd make that clear. |
Sorry, something went wrong.
|
@pganssle yeah I was a little ambivalent. I guess it wouldn't hurt anyway. Here it is: lapointe.xavier@protonmail.com |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Description
I just found an edge case (I believe) that was not handled properly. It seems like the slice on the TZ environment variable value was incorrect, using name[:-1] instead of name[1:].
I would end up with the following:
... instead of:
/etc/localtime
Background
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