Detect if DST is in effect

This commit is contained in:
spla 2021-05-03 15:07:42 +02:00
pare eb2df2d0a8
commit c3027ccd04
S'han modificat 1 arxius amb 11 adicions i 2 eliminacions

Veure arxiu

@ -4,6 +4,7 @@ import os.path
import re
import unidecode
from datetime import datetime, timedelta
import time
from mastodon import Mastodon
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
@ -246,6 +247,14 @@ def get_mentions():
status_id_lst = []
if time.localtime().tm_isdst == 0:
interval_time = '60 minutes'
elif time.localtime().tm_isdst == 1:
interval_time = '120 minutes'
conn = None
try:
@ -254,7 +263,7 @@ def get_mentions():
cur = conn.cursor()
select_query = "select account_id, id from statuses where created_at + interval '60 minutes' > now() - interval '5 minutes'"
select_query = "select account_id, id from statuses where created_at + interval '" + interval_time + "' > now() - interval '5 minutes'"
select_query += " and id=any (select status_id from mentions where account_id=(%s)) order by created_at asc"
cur.execute(select_query, (str(bot_id),))