Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #94811
| Path | csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.datemas.de!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Newsgroups | comp.lang.python, comp.unix.shell |
| Subject | Convert between timezones (was: How to re-write this bash script in Python?) |
| Followup-To | comp.unix.shell |
| Date | Fri, 31 Jul 2015 12:35:29 +0200 |
| Organization | PointedEars Software (PES) |
| Lines | 40 |
| Message-ID | <2716432.pTP2q8pAs5@PointedEars.de> (permalink) |
| References | <CAPTjJmoKYt3=fmz0q=azgVCXTs0YCfeiJZ3fYCSVe7cEzAHkPw@mail.gmail.com> <20150731081503.GA12474@cskk.homeip.net> <mailman.1112.1438331201.3674.python-list@python.org> |
| Reply-To | Thomas 'PointedEars' Lahn <usenet@PointedEars.de> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="UTF-8" |
| Content-Transfer-Encoding | 8Bit |
| X-Trace | solani.org 1438339129 15323 eJwFwQkRADAIAzBLPKWAnG0c/iUsCafyJRhEbOx4pAq8p0sBvtpanfY0y7kmKcZDWVSbjH76hw+5 (31 Jul 2015 10:38:49 GMT) |
| X-Complaints-To | abuse@news.solani.org |
| NNTP-Posting-Date | Fri, 31 Jul 2015 10:38:49 +0000 (UTC) |
| User-Agent | KNode/4.14.2 |
| X-User-ID | eJwFwYEBwCAIA7CXdG1BzgGU/09YIti2dpqMGk3oQY+B7E2gnBevsmbxDHea9wd8887IqYrbHoyVTBjW/QFOGBU3 |
| Cancel-Lock | sha1:ydbhzKF0+vh5xRIN9WcvqrCx9H0= |
| X-NNTP-Posting-Host | eJwFwYEBgDAIA7CXVoEWznEI/59gEkaw5Qx6bCyP7eU+yDJYoVzvMCJtxOoWllf+TSpdOD8AmhAE |
| Xref | csiph.com comp.lang.python:94811 comp.unix.shell:11973 |
Cross-posted to 2 groups.
Followups directed to: comp.unix.shell
Show key headers only | View raw
[X-Post & F'up2 comp.unix.shell] Chris Angelico wrote: > On Fri, Jul 31, 2015 at 6:15 PM, Cameron Simpson <cs@zip.com.au> wrote: >> Actually, bash has no timezone support but the date command _does_, and >> probably neither better nor worse than Python. All one has to do is set >> the TZ environment variable, eg (untested): >> >> _year_gmt=$( TZ=GMT date +%Y ) > > That's assuming that it's converting against the current system > timezone. I don't know how you'd use `date` to convert between two > arbitrary timezones. […] With POSIX date(1), ISTM all you could do is set the system time and for an additional invocation the TZ variable accordingly for output. <http://pubs.opengroup.org/onlinepubs/9699919799/utilities/date.html> With GNU date(1): $ (tz_source="Asia/Dubai"; time_source="$(LC_TIME=C TZ=$tz_source date -d "today 00:00 UTC+4" -Im)"; tz_target="America/Chicago"; echo "When it was $time_source in $tz_source, it was $(LC_TIME=C TZ=$tz_target date -d "$time_source") in $tz_target.") When it was 2015-07-31T00:00+0400 in Asia/Dubai, it was Thu Jul 30 15:00:00 CDT 2015 in America/Chicago. $ date --version date (GNU coreutils) 8.23 […] :) -- PointedEars Twitter: @PointedEars2 Please do not cc me. / Bitte keine Kopien per E-Mail.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: How to re-write this bash script in Python? Chris Angelico <rosuav@gmail.com> - 2015-07-31 18:26 +1000
Convert between timezones (was: How to re-write this bash script in Python?) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-31 12:35 +0200
Re: Convert between timezones Akira Li <4kir4.1i@gmail.com> - 2015-08-01 03:39 +0300
csiph-web