localtz() function doesnt work properly

Bug #2052593 reported by Radovan Pieter
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
YAQL
Fix Released
Medium
Radovan Pieter

Bug Description

Hi, i came across problem with localtz() function. Per your documentation I understand localtz() function returns timezone information by returning offset seconds to UTC TZ.

But in code there's bad if statement (line 325: https://opendev.org/openstack/yaql/src/branch/master/yaql/standard_library/date_time.py#L325) - there is used parameter "time.daylight" which does NOT indicate whether there is currently DST active. It only (per issues found on internet) indicates whether the TZ does or does not have DST.

You should better use time.localtime().tm_isdst which really indicates if DST is active or not.

- We have usecase where we use yaql localtz() to get current time: now(offset=>localtz()).format("%Y-%m-%d %H:%M")
-- But this approach is not correct now because it now return DST time (so +1hour to real time).
Issue i reffered to: https://bugs.python.org/issue7229

----

Closes-Bug: #2052593

description: updated
description: updated
Changed in yaql:
status: New → In Progress
importance: Undecided → Medium
assignee: nobody → Radovan Pieter (the-rdvn)
description: updated
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to yaql (master)

Reviewed: https://review.opendev.org/c/openstack/yaql/+/908288
Committed: https://opendev.org/openstack/yaql/commit/269f9669965a6d757ff8aaa6683f37b8e9a0f27d
Submitter: "Zuul (22348)"
Branch: master

commit 269f9669965a6d757ff8aaa6683f37b8e9a0f27d
Author: Radovan Pieter <email address hidden>
Date: Wed Feb 7 12:09:27 2024 +0100

    Fix localtz() function

    Closes-Bug: #2052593
    Change-Id: I739b44829202f0edba94ff502cd06e6cba60a4d0

Changed in yaql:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.