Commit 489bb108 authored by Vincent Pelletier's avatar Vincent Pelletier

Toward Python3: floor division

parent 5c4d3570
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# #
############################################################################## ##############################################################################
from __future__ import print_function from __future__ import print_function, division
from cgi import escape from cgi import escape
from collections import defaultdict, Counter from collections import defaultdict, Counter
from datetime import datetime, timedelta, date from datetime import datetime, timedelta, date
...@@ -810,7 +810,7 @@ def _asWeekString(timestamp): ...@@ -810,7 +810,7 @@ def _asWeekString(timestamp):
offset = date(year, month, 1).timetuple().tm_yday - 2 offset = date(year, month, 1).timetuple().tm_yday - 2
_month_offset_cache[key] = offset _month_offset_cache[key] = offset
day_of_year = day + offset day_of_year = day + offset
day -= day_of_year - (day_of_year / 7 * 7) day -= day_of_year - (day_of_year // 7 * 7)
if day < 1: if day < 1:
month -= 1 month -= 1
day += calendar.monthrange(year, month)[1] day += calendar.monthrange(year, month)[1]
...@@ -819,11 +819,11 @@ def _asWeekString(timestamp): ...@@ -819,11 +819,11 @@ def _asWeekString(timestamp):
def _weekStringAsQuarterString(timestamp): def _weekStringAsQuarterString(timestamp):
year, month, _ = timestamp.split('/') year, month, _ = timestamp.split('/')
return '%s/%02i' % (year, (int(month) - 1) / 3 * 3 + 1) return '%s/%02i' % (year, (int(month) - 1) // 3 * 3 + 1)
def _roundWeek(dt): def _roundWeek(dt):
day_of_year = dt.timetuple().tm_yday day_of_year = dt.timetuple().tm_yday
return dt - timedelta(day_of_year - ((day_of_year - 1) / 7 * 7 + 1)) return dt - timedelta(day_of_year - ((day_of_year - 1) // 7 * 7 + 1))
def _getWeekCoefficient(dt): def _getWeekCoefficient(dt):
if dt.month != 12: if dt.month != 12:
...@@ -842,10 +842,10 @@ def _as6HourString(timestamp): ...@@ -842,10 +842,10 @@ def _as6HourString(timestamp):
dt_date, hour, _ = dt.split(':', 2) dt_date, hour, _ = dt.split(':', 2)
day, month, year = dt_date.split('/') day, month, year = dt_date.split('/')
return '%s/%02i/%s %02i' % (year, MONTH_VALUE_DICT[month], day, return '%s/%02i/%s %02i' % (year, MONTH_VALUE_DICT[month], day,
int(hour) / 6 * 6) int(hour) // 6 * 6)
def _round6Hour(dt): def _round6Hour(dt):
return dt.replace(hour=dt.hour / 6 * 6) return dt.replace(hour=dt.hour // 6 * 6)
def _hourAsWeekString(timestamp): def _hourAsWeekString(timestamp):
dt = datetime.strptime(timestamp, '%Y/%m/%d %H') dt = datetime.strptime(timestamp, '%Y/%m/%d %H')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment