8000 Python: Respect `fold` attribute provided by `datetime.tzinfo` by rcrdnalor · Pull Request #1090 · MythTV/mythtv · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Python: Respect fold attribute provided by datetime.tzinfo #1090

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

Merged
merged 1 commit into from
May 13, 2025

Conversation

rcrdnalor
Copy link
Contributor

Python3.13 takes the fold attribute into account when crating various MythTV.datetime objects. This attribute is used to disambiguate datetime objects during transition from daylight saving time to standard time, where the local time stamp occurs twice.

Found in the changelog of python 3.13:
gh-89039: When replace() method is called on a subclass of datetime, date or time, properly call derived constructor. Previously, only the base class’s constructor was called.
Also, make sure to pass non-zero fold values when creating subclasses in various methods. Previously, fold was silently ignored.

Refs: MythTV.#1083

Python3.13 takes the `fold` attribute into account when crating various
`MythTV.datetime` objects. This attribute is used to disambiguate
`datetime` objects during transition from daylight saving time
to standard time, where the local time stamp occurs twice.

Found in the changelog of pyzthon 3.13:
gh-89039: When replace() method is called on a subclass of datetime, date or time,
properly call derived constructor. Previously, only the base class’s constructor was called.
Also, make sure to pass non-zero fold values when creating subclasses in various methods.
Previously, fold was silently ignored.

Refs: MythTV.MythTV#1083
@rcrdnalor
8000 Copy link
Contributor Author

Needs to be tested on

  • MythTV.MythDB().searchRecorded()
  • MythTV.MythBE().getRecordings()

The former uses MySQL statements to get the datetime objects,
the latter one uses the Protocol API provided by MythTV

Unfortunately, during 15 years of making recordings with MythTV,
I do not have a recording which was made during DST --> DT conversion.
Thus, I need to fake my mythconverg database.

@richardfearn
Copy link

@rcrdnalor Thank you for this!

Unfortunately, during 15 years of making recordings with MythTV,
I do not have a recording which was made during DST --> DT conversion.
Thus, I need to fake my mythconverg database.

I do still have the 'bad' recording on my system so I will try your change too!

@richardfearn
Copy link
richardfearn commented May 13, 2025

MythTV.MythBE().getRecordings()

This one now works:

>>> import MythTV
>>> list(MythTV.MythBE().getRecordings())[35].endtime
datetime(2022, 10, 30, 1, 45, fold=1, tzinfo=zoneinfo.ZoneInfo(key='localtime'))

(getRecordings works, and the 'bad' recording's endtime has fold=1)

@richardfearn
Copy link

MythTV.MythDB().searchRecorded()

Also works for this one:

>>> import MythTV
>>> list(MythTV.MythDB().searchRecorded())[60].endtime
datetime(2022, 10, 30, 1, 55, fold=1, tzinfo=zoneinfo.ZoneInfo(key='localtime'))

@rcrdnalor rcrdnalor marked this pull request as ready for review May 13, 2025 19:40
@rcrdnalor
Copy link
Contributor Author

@richardfearn Thank you very much for analysing and testing this issue.
If nothing pops up on mythtv/master, it will be merged to mythtv/fixes35 soon.

@rcrdnalor rcrdnalor merged commit b577909 into MythTV:master May 13, 2025
6 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0