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

Unified Diff: appengine/findit/common/time_util.py

Issue 2043973002: [Findit] Fracas crash triage dashboard (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Surpass pylint errors. Created 4 years, 6 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/findit/common/test/time_util_test.py ('k') | appengine/findit/crash/fracas.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/findit/common/time_util.py
diff --git a/appengine/findit/common/time_util.py b/appengine/findit/common/time_util.py
new file mode 100644
index 0000000000000000000000000000000000000000..e9257f0a32b8d3c6d0a95869471d5a70d32513bc
--- /dev/null
+++ b/appengine/findit/common/time_util.py
@@ -0,0 +1,27 @@
+# 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.
+
+from datetime import datetime
+from datetime import time
+from datetime import timedelta
+
+
+def RemoveMicrosecondsFromDelta(delta):
+ """Returns a timedelta object without microseconds based on delta."""
+ return delta - timedelta(microseconds=delta.microseconds)
+
+
+def FormatTimedelta(delta):
+ if not delta:
+ return None
+ hours, remainder = divmod(delta.seconds, 3600)
+ minutes, seconds = divmod(remainder, 60)
+ return '%02d:%02d:%02d' % (hours, minutes, seconds)
+
+
+def FormatDatetime(date):
+ if not date:
+ return None
+ else:
+ return date.strftime('%Y-%m-%d %H:%M:%S UTC')
« no previous file with comments | « appengine/findit/common/test/time_util_test.py ('k') | appengine/findit/crash/fracas.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698