-
Notifications
You must be signed in to change notification settings - Fork 206
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
localtime version of sec2gmt #170
Comments
Thanks for asking. In my professional life I've seen many systems be bitten hard by timezone issues so I was reluctant to step into that unless someone really wanted the feature. That said, I'm still iterating and I don't have all unit tests written out, but, at present in head, I have:
Those are key-stroke savers for frequently-used
These simply require you to set the The C library has a few quirks for timezone handling which I'm passing along:
|
Thanks! I tested it, and while strftime_local seems to work
fine, strptime_local does not seem to have "taken" -- I get an
error saying:
mlr: Function name "strptime_local" not found.
(Just in case, I've attached my test sequence, paltry as it is).
I realise that setting an arbitrary timezone may be needed by
some people (eventually you'll certainly get asked that), but
for my purposes, setting TZ outside and using that to get local
stuff is suffiall I need.
As for your second caveat about TZ misspellings, well that's
true for the humble 'date' command also so I wouldn't worry
about it!
thanks again
sitaram
…On Sat, Apr 28, 2018 at 06:41:23PM -0700, John Kerl wrote:
Thanks for asking.
In my professional life I've seen many systems be bitten hard by timezone issues so I was reluctant to step into that unless someone really wanted the feature.
That said, `strftime` and `strptime`, in the C library under the hood, do support local timezones so it's a matter of exposing that.
I'm still iterating and I don't have all unit tests written out, but, at present in head, I have:
* `sec2gmt` and `sec2localtime`
* `sec2gmtdate` and `sec2localdate`
* `gmt2sec` and `localtime2sec`
Those are key-stroke savers for frequently-used `Y-m-d H:M:S` format strings. Then more generally:
* `strftime` and `strftime_local`
* `strptime` and `strptime_local`
These simply require you to set the `TZ` environment variable, e.g. `export TZ=America/Manaus` or `export TZ=UTC+05:30`.
The C library has a few quirks for timezone handling which I'm passing along:
* There's no clear way I can tell to programatically set arbitrary timezone, e.g. for there to be a Miller function with arbitrary timezone as an argument so you could produce multiple timezones in a single run of the executable. (A hack would be for me to implement this by setting `TZ` within the Miller C program.)
* When a timezone is misspelled, even by a single character, UTC is silently used.
--
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#170 (comment)
|
oh I forgot the attachment; sorry. Here it is |
yes, it's still under development -- I'm not done & have not closed the task out. |
P.S. re "In my professional life I've seen many systems be bitten hard by timezone issues so I was reluctant to step into that unless someone really wanted the feature." -- what I meant to say was "In my professional life I've seen many systems be bitten hard by daylight-savings-time issues". Here:
So it will come with caveats. |
OK everything is pushed. 59ca76b shows the test cases, focusing on DST changes. Something's not right though:
Namely |
This is illuminating:
Meanwhile
and
This means:
Miller isn't being clever in its use of So apparently the system |
Interesting. As you said, lots of issues.
Speaking for myself, I'd be fine if you just document the caveats with a
couple of examples (or just refer to this thread/issue), and leave it at
that. But that may be because India doesn't *have* DST so this
is unlikely to affect me; it is possible others will need more than that.
Thank you once again for your efforts.
|
OK @sitaramc ... what's in head at the moment will definitely work for your no-DST case. And whatever mods I make from here on out, won't break non-DST. :) |
In order to use libc's capacity to automatically set According to the OpenBSD
The GNU strptime manpage isn't as clear as this, but according to both the GNU and OpenBSD @johnkerl, would you be interested in a PR that modifies |
I need a way to convert epoch seconds to localtime instead of GMT.
Currently there seems to be no way to do that. (I've tried all kinds of formats with strftime too).
The text was updated successfully, but these errors were encountered: