| OLD | NEW |
| 1 # This file is part of the Adblock Plus web scripts, | 1 # This file is part of the Adblock Plus web scripts, |
| 2 # Copyright (C) 2006-2016 Eyeo GmbH | 2 # Copyright (C) 2006-2016 Eyeo GmbH |
| 3 # | 3 # |
| 4 # Adblock Plus is free software: you can redistribute it and/or modify | 4 # Adblock Plus is free software: you can redistribute it and/or modify |
| 5 # it under the terms of the GNU General Public License version 3 as | 5 # it under the terms of the GNU General Public License version 3 as |
| 6 # published by the Free Software Foundation. | 6 # published by the Free Software Foundation. |
| 7 # | 7 # |
| 8 # Adblock Plus is distributed in the hope that it will be useful, | 8 # Adblock Plus is distributed in the hope that it will be useful, |
| 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 # GNU General Public License for more details. | 11 # GNU General Public License for more details. |
| 12 # | 12 # |
| 13 # You should have received a copy of the GNU General Public License | 13 # You should have received a copy of the GNU General Public License |
| 14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 15 | 15 |
| 16 import re | 16 import re |
| 17 import email.header | 17 import email.header |
| 18 import email.utils | 18 import email.utils |
| 19 import urllib | 19 import urllib |
| 20 import time | 20 import time |
| 21 import json | 21 import json |
| 22 from datetime import date | 22 from datetime import date |
| 23 from jinja2.utils import Markup | 23 from jinja2.utils import Markup |
| 24 from urlparse import urlparse | 24 from urlparse import urlparse |
| 25 | 25 |
| 26 | 26 |
| 27 def formattime(value): | 27 def formattime(value): |
| 28 try: | 28 try: |
| 29 return time.strftime('%Y-%m-%d %H:%M UTC', time.gmtime(int(value))) | 29 return time.strftime('%Y-%m-%d %H:%M UTC', time.gmtime(int(value))) |
| 30 except Exception, e: | 30 except Exception as e: |
| 31 return 'unknown' | 31 return 'unknown' |
| 32 | 32 |
| 33 | 33 |
| 34 def formatrelativetime(value, baseTime): | 34 def formatrelativetime(value, baseTime): |
| 35 try: | 35 try: |
| 36 value = float(value) | 36 value = float(value) |
| 37 params = {'title': formattime(baseTime + value), 'number': value, 'prefi
x': 'in ', 'suffix': '', 'unit': 'second(s)'} | 37 params = {'title': formattime(baseTime + value), 'number': value, 'prefi
x': 'in ', 'suffix': '', 'unit': 'second(s)'} |
| 38 if params['number'] < 0: | 38 if params['number'] < 0: |
| 39 params['prefix'] = '' | 39 params['prefix'] = '' |
| 40 params['suffix'] = ' ago' | 40 params['suffix'] = ' ago' |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 'subscriptionSort': subscriptionSort, | 198 'subscriptionSort': subscriptionSort, |
| 199 'mime': formatmime, | 199 'mime': formatmime, |
| 200 'emailaddr': email.utils.formataddr, | 200 'emailaddr': email.utils.formataddr, |
| 201 'ljust': ljust, | 201 'ljust': ljust, |
| 202 'rjust': rjust, | 202 'rjust': rjust, |
| 203 'ltruncate': ltruncate, | 203 'ltruncate': ltruncate, |
| 204 'weekday': formatweekday, | 204 'weekday': formatweekday, |
| 205 'bytes': formatbytes, | 205 'bytes': formatbytes, |
| 206 'json': toJSON, | 206 'json': toJSON, |
| 207 } | 207 } |
| OLD | NEW |