Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: third_party/logilab/common/date.py

Issue 753543006: pylint: upgrade to 1.4.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/logilab/common/daemon.py ('k') | third_party/logilab/common/dbf.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved. 1 # copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr 2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
3 # 3 #
4 # This file is part of logilab-common. 4 # This file is part of logilab-common.
5 # 5 #
6 # logilab-common is free software: you can redistribute it and/or modify it unde r 6 # logilab-common is free software: you can redistribute it and/or modify it unde r
7 # the terms of the GNU Lesser General Public License as published by the Free 7 # the terms of the GNU Lesser General Public License as published by the Free
8 # Software Foundation, either version 2.1 of the License, or (at your option) an y 8 # Software Foundation, either version 2.1 of the License, or (at your option) an y
9 # later version. 9 # later version.
10 # 10 #
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 if isinstance(somedate, datetime): 307 if isinstance(somedate, datetime):
308 fields.update({'H': somedate.hour, 308 fields.update({'H': somedate.hour,
309 'M': somedate.minute, 309 'M': somedate.minute,
310 'S': somedate.second}) 310 'S': somedate.second})
311 fmt = re.sub('%([YmdHMS])', r'%(\1)02d', fmt) 311 fmt = re.sub('%([YmdHMS])', r'%(\1)02d', fmt)
312 return unicode(fmt) % fields 312 return unicode(fmt) % fields
313 313
314 def utcdatetime(dt): 314 def utcdatetime(dt):
315 if dt.tzinfo is None: 315 if dt.tzinfo is None:
316 return dt 316 return dt
317 return datetime(*dt.utctimetuple()[:7]) 317 return (dt.replace(tzinfo=None) - dt.utcoffset())
318 318
319 def utctime(dt): 319 def utctime(dt):
320 if dt.tzinfo is None: 320 if dt.tzinfo is None:
321 return dt 321 return dt
322 return (dt + dt.utcoffset() + dt.dst()).replace(tzinfo=None) 322 return (dt + dt.utcoffset() + dt.dst()).replace(tzinfo=None)
323 323
324 def datetime_to_seconds(date): 324 def datetime_to_seconds(date):
325 """return the number of seconds since the begining of the day for that date 325 """return the number of seconds since the begining of the day for that date
326 """ 326 """
327 return date.second+60*date.minute + 3600*date.hour 327 return date.second+60*date.minute + 3600*date.hour
328 328
329 def timedelta_to_days(delta): 329 def timedelta_to_days(delta):
330 """return the time delta as a number of seconds""" 330 """return the time delta as a number of seconds"""
331 return delta.days + delta.seconds / (3600*24) 331 return delta.days + delta.seconds / (3600*24)
332 332
333 def timedelta_to_seconds(delta): 333 def timedelta_to_seconds(delta):
334 """return the time delta as a fraction of days""" 334 """return the time delta as a fraction of days"""
335 return delta.days*(3600*24) + delta.seconds 335 return delta.days*(3600*24) + delta.seconds
OLDNEW
« no previous file with comments | « third_party/logilab/common/daemon.py ('k') | third_party/logilab/common/dbf.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698