Fix Poll.duration rounding error

This commit is contained in:
ambdroid
2024-08-28 15:31:38 -04:00
committed by GitHub
parent da89fbc8b5
commit 38bbfed717

View File

@ -384,9 +384,9 @@ class Poll:
question_data = data.get('question')
question = question_data.get('text')
expiry = utils.parse_time(data['expiry']) # If obtained via API, then expiry is set.
duration = expiry - message.created_at
# expiry - message.created_at may be a few nanos away from the actual duration
duration = datetime.timedelta(hours=round((expiry - message.created_at).total_seconds() / 3600))
# self.created_at = message.created_at
# duration = self.created_at - expiry
self = cls(
duration=duration,