Search code examples
pythonpython-3.xtrello

Trello always adding 1 hour to my Date


I have a script that sets some Trello cards for me. Everything is working but card due date. Let's say I have the following dates that I got from my SQLite DB:

2016-03-30 23:55:00
2016-05-02 23:55:00    
2016-09-30 23:55:00

When I run my code, Trello will set them on the cards as:

2016-03-31 00:55:00
2016-05-03 00:55:00    
2016-10-01 00:55:00

As you can see, due dates on my Trello cards are always 1 hour ahead when they shouldn't. How can I fix that?

Code used: trello.cards.update_due(card["id"], assignment.due_date)

Function:

def update_due(self, card_id, value):
    resp = requests.put("https://trello.com/1/cards/%s/due" % card_id, params=dict(key=self._apikey, token=self._token), data=dict(value=value))
    resp.raise_for_status()
    return json.loads(resp.content.decode('utf-8'))

MORE DETAILS

import dateparser
from datetime import datetime

str_date = 'segunda, 2 Mai 2016, 23:55'  # This is GMT-3 time
tsp = dateparser.parse(str_date, languages=['pt']).timestamp()  # https://dateparser.readthedocs.io/en/latest
print(tsp, type(tsp))  # returns: 1462244100.0 <class 'float'>
trello.cards.update_due(card["id"], datetime.fromtimestamp(tsp))  # sets a due time of May 3 at 12:55AM on Trello

Solution

  • I found a fix, I needed to set settings={'TIMEZONE': 'America/Sao_Paulo'} on my parse(). Working now!