From 60892d4718c696735970f2e2e41c23558895a1e0 Mon Sep 17 00:00:00 2001 From: Michael Moliterno Date: Thu, 12 May 2016 01:12:48 -0500 Subject: [PATCH] added card_created_date() function --- trello/card.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/trello/card.py b/trello/card.py index 6c1e963a..218b37cd 100644 --- a/trello/card.py +++ b/trello/card.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import with_statement, print_function, absolute_import from dateutil import parser as dateparser +from datetime import datetime from trello.checklist import Checklist from trello.label import Label @@ -268,6 +269,24 @@ def create_date(self): date_str = self.actions[0]['date'] return dateparser.parse(date_str) + @property + def card_created_date(self): + """Will return the creation date of the card. + + NOTE: This will return the date the card was created, even if it + was created on another board. The created_date() above actually just + returns the first activity and has the issue described in the warning. + + The first 8 characters of the card id is a hexadecimal number. + Converted to a decimal from hexadecimal, the timestamp is an Unix + timestamp (the number of seconds that have elapsed since January 1, + 1970 midnight UTC.See + http://help.trello.com/article/759-getting-the-time-a-card-or-board-was-created + """ + unix_time = int(self.id[:8],16) + + return datetime.fromtimestamp(unix_time) + @property def due_date(self): return dateparser.parse(self.due) if self.due else ''