From 502536f4b67b7ebdf66540db2db2475cc4e1fefe Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Tue, 20 Feb 2018 23:22:31 -0500 Subject: [PATCH] Fix #2652 by using local timestamps Because users write their queries in local time, we want to get a local time tuple from the timestamp stored in the database. --- beets/dbcore/query.py | 2 +- docs/changelog.rst | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/beets/dbcore/query.py b/beets/dbcore/query.py index fbe6626c7..8fb64e206 100644 --- a/beets/dbcore/query.py +++ b/beets/dbcore/query.py @@ -708,7 +708,7 @@ class DateQuery(FieldQuery): if self.field not in item: return False timestamp = float(item[self.field]) - date = datetime.utcfromtimestamp(timestamp) + date = datetime.fromtimestamp(timestamp) return self.interval.contains(date) _clause_tmpl = "{0} {1} ?" diff --git a/docs/changelog.rst b/docs/changelog.rst index 4381edeeb..4f00b123b 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -46,6 +46,11 @@ Fixes: * Avoid a crash when importing a non-ASCII filename when using an ASCII locale on Unix under Python 3. :bug:`2793` :bug:`2803` +* Fix a problem caused by time zone misalignment that could make date queries + fail to match certain dates that are near the edges of a range. For example, + querying for dates within a certain month would fail to match dates within + hours of the end of that month. + :bug:`2652` 1.4.6 (December 21, 2017)