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


Groups > comp.lang.python > #20190 > unrolled thread

datetime module and timezone

Started byOlive <diolu@bigfoot.com>
First post2012-02-10 22:25 +0100
Last post2012-02-11 08:51 +0000
Articles 5 — 5 participants

Back to article view | Back to comp.lang.python


Contents

  datetime module and timezone Olive <diolu@bigfoot.com> - 2012-02-10 22:25 +0100
    Re: datetime module and timezone John Gordon <gordon@panix.com> - 2012-02-10 21:30 +0000
    Re: datetime module and timezone Chris Rebert <clp2@rebertia.com> - 2012-02-10 14:00 -0800
    Re: datetime module and timezone Bob Martin <bob.martin@excite.com> - 2012-02-11 07:05 +0000
      Re: datetime module and timezone all mail refused <elvis-85496@notatla.org.uk> - 2012-02-11 08:51 +0000

#20190 — datetime module and timezone

FromOlive <diolu@bigfoot.com>
Date2012-02-10 22:25 +0100
Subjectdatetime module and timezone
Message-ID<20120210222545.4cbe6924@bigfoot.com>
In the datetime module, it has support for a notion of timezone but is
it possible to use one of the available timezone (I am on Linux). Linux
has a notion of timezone (in my distribution, they are stored
in /usr/share/zoneinfo). I would like to be able 1) to know the current
timezone and 2) to be able to use the timezone available on the system.
How can I do that?

Olive

[toc] | [next] | [standalone]


#20192

FromJohn Gordon <gordon@panix.com>
Date2012-02-10 21:30 +0000
Message-ID<jh428v$2dg$1@reader1.panix.com>
In reply to#20190
In <20120210222545.4cbe6924@bigfoot.com> Olive <diolu@bigfoot.com> writes:

> In the datetime module, it has support for a notion of timezone but is
> it possible to use one of the available timezone (I am on Linux). Linux
> has a notion of timezone (in my distribution, they are stored
> in /usr/share/zoneinfo). I would like to be able 1) to know the current
> timezone and 2) to be able to use the timezone available on the system.
> How can I do that?

I believe the current user's timezone is stored in the TZ environment
variable.

I don't understand your second question.  Are you asking for a list of
of all the possible timezone choices?

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

[toc] | [prev] | [next] | [standalone]


#20194

FromChris Rebert <clp2@rebertia.com>
Date2012-02-10 14:00 -0800
Message-ID<mailman.5681.1328911220.27778.python-list@python.org>
In reply to#20190
On Fri, Feb 10, 2012 at 1:25 PM, Olive <diolu@bigfoot.com> wrote:
> In the datetime module, it has support for a notion of timezone but is
> it possible to use one of the available timezone (I am on Linux). Linux
> has a notion of timezone (in my distribution, they are stored
> in /usr/share/zoneinfo). I would like to be able 1) to know the current
> timezone

time.tzname gives the zone names (plural due to DST); time.timezone
and time.altzone gives their UTC offsets.

> and 2) to be able to use the timezone available on the system.

You can use the name to look it up in pytz (http://pypi.python.org/pypi/pytz/ ).
And python-dateutil (http://labix.org/python-dateutil ) can apparently
parse zoneinfo files, if that's what you mean.

Cheers,
Chris

[toc] | [prev] | [next] | [standalone]


#20213

FromBob Martin <bob.martin@excite.com>
Date2012-02-11 07:05 +0000
Message-ID<9pmi9iFufgU1@mid.individual.net>
In reply to#20190
in 671891 20120210 212545 Olive <diolu@bigfoot.com> wrote:
>In the datetime module, it has support for a notion of timezone but is
>it possible to use one of the available timezone (I am on Linux). Linux
>has a notion of timezone (in my distribution, they are stored
>in /usr/share/zoneinfo). I would like to be able 1) to know the current
>timezone and 2) to be able to use the timezone available on the system.
>How can I do that?

For 1) just type "date" on the command line.

[toc] | [prev] | [next] | [standalone]


#20216

Fromall mail refused <elvis-85496@notatla.org.uk>
Date2012-02-11 08:51 +0000
Message-ID<slrnjjcavl.cb6.elvis-85496@notatla.org.uk>
In reply to#20213
On 2012-02-11, Bob Martin <bob.martin@excite.com> wrote:
> in 671891 20120210 212545 Olive <diolu@bigfoot.com> wrote:
>>In the datetime module, it has support for a notion of timezone but is
>>it possible to use one of the available timezone (I am on Linux). Linux
>>has a notion of timezone (in my distribution, they are stored
>>in /usr/share/zoneinfo). I would like to be able 1) to know the current
>>timezone

> For 1) just type "date" on the command line.

But "date" gets it from somewhere else (otherwise infinite loop).
If there's no environment variable it seems to use files like these.
open("/usr/lib/locale/en_GB.utf8/LC_TIME", O_RDONLY) = 3
..
open("/etc/localtime", O_RDONLY)        = 3


-- 
Elvis Notargiacomo  master AT barefaced DOT cheek

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web