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 re
import unidecode import unidecode
from datetime import datetime, timedelta from datetime import datetime, timedelta
import time
from mastodon import Mastodon from mastodon import Mastodon
from email.mime.multipart import MIMEMultipart from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText from email.mime.text import MIMEText
@ -241,11 +242,19 @@ def get_piece_name(captured_piece):
return piece_name return piece_name
def get_mentions(): def get_mentions():
account_id_lst = [] account_id_lst = []
status_id_lst = [] 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 conn = None
try: try:
@ -254,7 +263,7 @@ def get_mentions():
cur = conn.cursor() 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" 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),)) cur.execute(select_query, (str(bot_id),))