Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #94806

Re: How to re-write this bash script in Python?

References <CAPTjJmoKYt3=fmz0q=azgVCXTs0YCfeiJZ3fYCSVe7cEzAHkPw@mail.gmail.com> <20150731081503.GA12474@cskk.homeip.net>
Date 2015-07-31 18:26 +1000
Subject Re: How to re-write this bash script in Python?
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1112.1438331201.3674.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Jul 31, 2015 at 6:15 PM, Cameron Simpson <cs@zip.com.au> wrote:
>> For example, bash lacks
>> decent timezone support, so I can well believe random832's guess that
>> your five-hour offset is a simulation of that; but Python can do much
>> better work with timezones, so you can get that actually correct.
>
>
> 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. But anyway, still justification to rewrite from
original spec rather than reimplementing the five-hour hack.

ChrisA

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


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