diff options
author | Bruno Wagner <bwagner@thoughtworks.com> | 2014-10-17 18:53:59 +0200 |
---|---|---|
committer | Bruno Wagner <bwagner@thoughtworks.com> | 2014-10-17 18:53:59 +0200 |
commit | 880bba5dd4cb370809c7a949719f015cae3126fa (patch) | |
tree | 82ba1a296bd1dae6af1c367a5c8977c223a0ea8d /service/pixelated/support | |
parent | b2cd7c9846a50c67571b9ff7596ce7822881713d (diff) |
Date is now stored as number, and is correctly used for sorting
Diffstat (limited to 'service/pixelated/support')
-rw-r--r-- | service/pixelated/support/date.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/service/pixelated/support/date.py b/service/pixelated/support/date.py index 329b8bfe..8a2daaf0 100644 --- a/service/pixelated/support/date.py +++ b/service/pixelated/support/date.py @@ -14,9 +14,18 @@ # You should have received a copy of the GNU Affero General Public License # along with Pixelated. If not, see <http://www.gnu.org/licenses/>. import datetime +import dateutil.parser from dateutil.tz import tzlocal def iso_now(): return datetime.datetime.now(tzlocal()).isoformat() + + +def milliseconds(date): + date = dateutil.parser.parse(date) + date = date.replace(tzinfo=None) + epoch = datetime.datetime.utcfromtimestamp(0) + delta = date - epoch + return int(delta.total_seconds() * 1000) |