| Index: appengine/findit/common/time_util.py
|
| diff --git a/appengine/findit/common/time_util.py b/appengine/findit/common/time_util.py
|
| deleted file mode 100644
|
| index 4ef6e8b8a41a167b34bb2a3d5fb090fadf27bf2a..0000000000000000000000000000000000000000
|
| --- a/appengine/findit/common/time_util.py
|
| +++ /dev/null
|
| @@ -1,68 +0,0 @@
|
| -# Copyright 2016 The Chromium Authors. All rights reserved.
|
| -# Use of this source code is governed by a BSD-style license that can be
|
| -# found in the LICENSE file.
|
| -
|
| -import calendar
|
| -from datetime import datetime
|
| -from datetime import time
|
| -from datetime import timedelta
|
| -
|
| -import pytz
|
| -
|
| -
|
| -def GetUTCNow(): # pragma: no cover.
|
| - """Returns the datetime.utcnow. This is to mock for testing."""
|
| - return datetime.utcnow()
|
| -
|
| -
|
| -def GetUTCNowWithTimezone(): # pragma: no cover.
|
| - """Returns datetime.now but in utc timezone. This is to mock for testing."""
|
| - return datetime.now(pytz.utc)
|
| -
|
| -
|
| -def GetUTCNowTimestamp(): # pragma: no cover.
|
| - """Returns the timestamp for datetime.utcnow. This is to mock for testing."""
|
| - return calendar.timegm(GetUTCNow().timetuple())
|
| -
|
| -
|
| -def RemoveMicrosecondsFromDelta(delta):
|
| - """Returns a timedelta object without microseconds based on delta."""
|
| - return delta - timedelta(microseconds=delta.microseconds)
|
| -
|
| -
|
| -def FormatTimedelta(delta):
|
| - """Returns a string representing the given time delta."""
|
| - if not delta:
|
| - return None
|
| - hours, remainder = divmod(delta.total_seconds(), 3600)
|
| - minutes, seconds = divmod(remainder, 60)
|
| - return '%02d:%02d:%02d' % (hours, minutes, seconds)
|
| -
|
| -
|
| -def FormatDatetime(date):
|
| - """Returns a string representing the given UTC datetime."""
|
| - if not date:
|
| - return None
|
| - else:
|
| - return date.strftime('%Y-%m-%d %H:%M:%S UTC')
|
| -
|
| -
|
| -def FormatDuration(datetime_start, datetime_end):
|
| - """Returns a string representing the given time duration or None."""
|
| - if not datetime_start or not datetime_end:
|
| - return None
|
| - return FormatTimedelta(datetime_end - datetime_start)
|
| -
|
| -
|
| -def GetDatetimeInTimezone(timezone_name, date_time):
|
| - """Returns the datetime.datetime of the given one in the specified timezone.
|
| -
|
| - Args:
|
| - timezone_name (str): The name of any timezone supported by pytz.
|
| - date_time (datetime.datetime): The optional datetime to be converted into
|
| - the new timezone.
|
| -
|
| - Returns:
|
| - A datetime.datetime of the given one in the specified timezone.
|
| - """
|
| - return date_time.astimezone(pytz.timezone(timezone_name))
|
|
|