|  | @@ -57,6 +57,8 @@ babel = Babel(app)
 | 
	
		
			
			| 57 | 57 |  favicons = ['wikipedia', 'youtube', 'vimeo', 'soundcloud',
 | 
	
		
			
			| 58 | 58 |              'twitter', 'stackoverflow', 'github']
 | 
	
		
			
			| 59 | 59 |  
 | 
	
		
			
			|  | 60 | +cookie_max_age = 60 * 60 * 24 * 365 * 23  # 23 years
 | 
	
		
			
			|  | 61 | +
 | 
	
		
			
			| 60 | 62 |  
 | 
	
		
			
			| 61 | 63 |  @babel.localeselector
 | 
	
		
			
			| 62 | 64 |  def get_locale():
 | 
	
	
		
			
			|  | @@ -159,8 +161,10 @@ def index():
 | 
	
		
			
			| 159 | 161 |  
 | 
	
		
			
			| 160 | 162 |          # TODO, check if timezone is calculated right
 | 
	
		
			
			| 161 | 163 |          if 'publishedDate' in result:
 | 
	
		
			
			| 162 |  | -            if result['publishedDate'].replace(tzinfo=None) >= datetime.now() - timedelta(days=1):
 | 
	
		
			
			| 163 |  | -                timedifference = datetime.now() - result['publishedDate'].replace(tzinfo=None)
 | 
	
		
			
			|  | 164 | +            if result['publishedDate'].replace(tzinfo=None)\
 | 
	
		
			
			|  | 165 | +               >= datetime.now() - timedelta(days=1):
 | 
	
		
			
			|  | 166 | +                timedifference = datetime.now() - result['publishedDate']\
 | 
	
		
			
			|  | 167 | +                    .replace(tzinfo=None)
 | 
	
		
			
			| 164 | 168 |                  minutes = int((timedifference.seconds / 60) % 60)
 | 
	
		
			
			| 165 | 169 |                  hours = int(timedifference.seconds / 60 / 60)
 | 
	
		
			
			| 166 | 170 |                  if hours == 0:
 | 
	
	
		
			
			|  | @@ -168,7 +172,8 @@ def index():
 | 
	
		
			
			| 168 | 172 |                  else:
 | 
	
		
			
			| 169 | 173 |                      result['publishedDate'] = gettext(u'{hours} hour(s), {minutes} minute(s) ago').format(hours=hours, minutes=minutes)  # noqa
 | 
	
		
			
			| 170 | 174 |              else:
 | 
	
		
			
			| 171 |  | -                result['pubdate'] = result['publishedDate'].strftime('%a, %d %b %Y %H:%M:%S %z')
 | 
	
		
			
			|  | 175 | +                result['pubdate'] = result['publishedDate']\
 | 
	
		
			
			|  | 176 | +                    .strftime('%a, %d %b %Y %H:%M:%S %z')
 | 
	
		
			
			| 172 | 177 |                  result['publishedDate'] = format_date(result['publishedDate'])
 | 
	
		
			
			| 173 | 178 |  
 | 
	
		
			
			| 174 | 179 |      if search.request_data.get('format') == 'json':
 | 
	
	
		
			
			|  | @@ -256,24 +261,21 @@ def preferences():
 | 
	
		
			
			| 256 | 261 |          user_blocked_engines = request.cookies.get('blocked_engines', '').split(',')  # noqa
 | 
	
		
			
			| 257 | 262 |  
 | 
	
		
			
			| 258 | 263 |          if sorted(blocked_engines) != sorted(user_blocked_engines):
 | 
	
		
			
			| 259 |  | -            # cookie max age: 4 weeks
 | 
	
		
			
			| 260 | 264 |              resp.set_cookie(
 | 
	
		
			
			| 261 | 265 |                  'blocked_engines', ','.join(blocked_engines),
 | 
	
		
			
			| 262 |  | -                max_age=60 * 60 * 24 * 7 * 4
 | 
	
		
			
			|  | 266 | +                max_age=cookie_max_age
 | 
	
		
			
			| 263 | 267 |              )
 | 
	
		
			
			| 264 | 268 |  
 | 
	
		
			
			| 265 | 269 |          if locale:
 | 
	
		
			
			| 266 |  | -            # cookie max age: 4 weeks
 | 
	
		
			
			| 267 | 270 |              resp.set_cookie(
 | 
	
		
			
			| 268 | 271 |                  'locale', locale,
 | 
	
		
			
			| 269 |  | -                max_age=60 * 60 * 24 * 7 * 4
 | 
	
		
			
			|  | 272 | +                max_age=cookie_max_age
 | 
	
		
			
			| 270 | 273 |              )
 | 
	
		
			
			| 271 | 274 |  
 | 
	
		
			
			| 272 | 275 |          if lang:
 | 
	
		
			
			| 273 |  | -            # cookie max age: 4 weeks
 | 
	
		
			
			| 274 | 276 |              resp.set_cookie(
 | 
	
		
			
			| 275 | 277 |                  'language', lang,
 | 
	
		
			
			| 276 |  | -                max_age=60 * 60 * 24 * 7 * 4
 | 
	
		
			
			|  | 278 | +                max_age=cookie_max_age
 | 
	
		
			
			| 277 | 279 |              )
 | 
	
		
			
			| 278 | 280 |  
 | 
	
		
			
			| 279 | 281 |          if selected_categories:
 |