Skip to content
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

Add tzset method to time module #37842

Closed
zenzen mannequin opened this issue Jan 27, 2003 · 11 comments
Closed

Add tzset method to time module #37842

zenzen mannequin opened this issue Jan 27, 2003 · 11 comments
Assignees
Labels
stdlib Python modules in the Lib dir

Comments

@zenzen
Copy link
Mannequin

zenzen mannequin commented Jan 27, 2003

BPO 675422
Nosy @gvanrossum
Files
  • tzset.patch: cvs diff -c path
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/gvanrossum'
    closed_at = <Date 2003-03-21.21:31:21.000>
    created_at = <Date 2003-01-27.13:42:14.000>
    labels = ['library']
    title = 'Add tzset method to time module'
    updated_at = <Date 2003-03-21.21:31:21.000>
    user = 'https://bugs.python.org/zenzen'

    bugs.python.org fields:

    activity = <Date 2003-03-21.21:31:21.000>
    actor = 'nnorwitz'
    assignee = 'gvanrossum'
    closed = True
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2003-01-27.13:42:14.000>
    creator = 'zenzen'
    dependencies = []
    files = ['4960']
    hgrepos = []
    issue_num = 675422
    keywords = ['patch']
    message_count = 11.0
    messages = ['42533', '42534', '42535', '42536', '42537', '42538', '42539', '42540', '42541', '42542', '42543']
    nosy_count = 3.0
    nosy_names = ['gvanrossum', 'nnorwitz', 'zenzen']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue675422'
    versions = ['Python 2.3']

    @zenzen
    Copy link
    Mannequin Author

    zenzen mannequin commented Jan 27, 2003

    Adds access to the tzset method, allowing you to change your local timezone as required. In addition to invoking the tzset system
    call, the code also updates the timezone attributes (time.timezone etc). This lets you do timezone conversions amongst other things.

    Also includes changes to configure.in to only build new code if the tzset method correctly switches timezones on your platform. This
    should be for all modern Unixes, and possibly other platforms.

    Also includes tests in test_time.py

    Docs would be along the lines of:

    tzset() --
    Initialize, or reinitialize, the local timezone to the value stored in os.environ['TZ']. The TZ environment variable should be specified in
    standard Uniz timezone format as documented in the tzset man page
    (eg. 'US/Eastern', 'Europe/Amsterdam'). Unknown timezones will silently fall back to UTC. If the TZ environment variable is not set, the local timezone is set to the systems best guess of wallclock time.
    Changing the TZ environment variable without calling tzset *may* change the local timezone used by methods such as localtime, but this behaviour should not be relied on.

    eg::

    >>> now = time.time()
    >>> os.environ['TZ'] = 'Europe/Amsterdam'
    >>> time.tzset()
    >>> time.ctime(now)
    'Mon Jan 27 14:35:17 2003'
    >>> time.tzname  
    ('CET', 'CEST')
    >>> os.environ['TZ'] = 'US/Eastern'
    >>> time.tzset()
    >>> time.ctime(now)
    'Mon Jan 27 08:35:17 2003'
    >>> time.tzname
    ('EST', 'EDT')

    @zenzen zenzen mannequin closed this as completed Jan 27, 2003
    @zenzen zenzen mannequin assigned gvanrossum Jan 27, 2003
    @zenzen zenzen mannequin added the stdlib Python modules in the Lib dir label Jan 27, 2003
    @zenzen zenzen mannequin closed this as completed Jan 27, 2003
    @zenzen zenzen mannequin assigned gvanrossum Jan 27, 2003
    @zenzen zenzen mannequin added the stdlib Python modules in the Lib dir label Jan 27, 2003
    @zenzen
    Copy link
    Mannequin Author

    zenzen mannequin commented Feb 21, 2003

    Logged In: YES
    user_id=46639

    Assigning to Guido for consideration of being added to
    2.2.3, and since he through this patch was a good idea in
    the first place :-)

    @gvanrossum
    Copy link
    Member

    Logged In: YES
    user_id=6380

    Uh? This is a new feature, so doesn't apply to 2.2.3.

    Maybe you meant 2.3?

    @zenzen
    Copy link
    Mannequin Author

    zenzen mannequin commented Feb 21, 2003

    Logged In: YES
    user_id=46639

    It is a patch to 2.3, but I'd though I'd try and sneak this
    new feature past people into 2.2.3 as I want to be able to
    use it in Zope 2 :-)

    @gvanrossum
    Copy link
    Member

    Logged In: YES
    user_id=6380

    Sorry, not a chance.

    @gvanrossum
    Copy link
    Member

    Logged In: YES
    user_id=6380

    zenzen: when I run the test suite on my Red Hat Linux 7.3
    box, I get one failure: the test line
    self.failUnless(time.tzname[0] in ('UTC','GMT'))
    fails when the timezone is set to 'Luna/Tycho', because
    tzname is in fact set to ('Luna/Tych', 'Luna/Tych').

    If I comment out that one line the tzset test suite passes.

    What should I do?

    @zenzen
    Copy link
    Mannequin Author

    zenzen mannequin commented Mar 8, 2003

    Logged In: YES
    user_id=46639

    Leave it commented out or remove that line. It is testing
    unimportant behaviour that looks more platform dependant
    than I suspected (and now I look at it again, what tzname
    should be set to if the timezone is unknow is unspecified by
    the tzset(3) docs). The important behaviour is that:

    a) the system silently falls back to UTC if the timezone is
    unknown, and this is tested elsewhere

    b) calling tzset resets tzname, which is also tested elsewhere.

    @gvanrossum
    Copy link
    Member

    Logged In: YES
    user_id=6380

    OK, checked in with that line removed.

    Thanks!

    @nnorwitz
    Copy link
    Mannequin

    nnorwitz mannequin commented Mar 20, 2003

    Logged In: YES
    user_id=33168

    test_time is now failing on Solaris 8. altzone is -3600,
    but should be 0. Also, is there a reason to compare
    timezone to altzone, but then check that each is 0 (line
    78)? Can you provide any suggestions for where to look for
    the problem?

    @zenzen
    Copy link
    Mannequin Author

    zenzen mannequin commented Mar 20, 2003

    Logged In: YES
    user_id=46639

    An update to this patch is now available:
    http://www.python.org/sf/706707

    @nnorwitz
    Copy link
    Mannequin

    nnorwitz mannequin commented Mar 21, 2003

    Logged In: YES
    user_id=33168

    Closing again, the problem can be addressed thru the other
    patch.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant