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

Unified Diff: appengine_apps/trooper_o_matic/appengine_module/trooper_o_matic/timezones.py

Issue 774323002: Moved trooper_o_matic to appengine/ (Closed) Base URL: https://chromium.googlesource.com/infra/infra.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 side-by-side diff with in-line comments
Download patch
Index: appengine_apps/trooper_o_matic/appengine_module/trooper_o_matic/timezones.py
diff --git a/appengine_apps/trooper_o_matic/appengine_module/trooper_o_matic/timezones.py b/appengine_apps/trooper_o_matic/appengine_module/trooper_o_matic/timezones.py
deleted file mode 100644
index 0dc791997d6517b7a3ebef00934570d9a91d0f4a..0000000000000000000000000000000000000000
--- a/appengine_apps/trooper_o_matic/appengine_module/trooper_o_matic/timezones.py
+++ /dev/null
@@ -1,71 +0,0 @@
-# Copyright (c) 2014 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.
-
-"""Converts between UTC and Pacific Time.
-
-From https://developers.google.com/appengine/docs/python/datastore/
- typesandpropertyclasses?csw=1#datetime
-TODO(sullivan): There has to be a simpler way. Look into pytz.
-"""
-import datetime
-import time
-
-
-# FIXME: Just use @staticmethod instead!
-# Unused argument - pylint: disable=W0613
-
-
-class UtcTzinfo(datetime.tzinfo):
-
- def utcoffset(self, dt):
- return datetime.timedelta(0)
-
- def dst(self, dt):
- return datetime.timedelta(0)
-
- def tzname(self, dt):
- return 'UTC'
-
- # pylint: disable=R0201
- def olsen_name(self):
- return 'UTC'
-
-
-class PacificTzinfo(datetime.tzinfo):
- """Implementation of the Pacific timezone."""
-
- def utcoffset(self, dt):
- return datetime.timedelta(hours=-8) + self.dst(dt)
-
- # pylint: disable=R0201
- def _FirstSunday(self, dt):
- """First Sunday on or after dt."""
- return dt + datetime.timedelta(days=(6-dt.weekday()))
-
- def dst(self, dt):
- # 2 am on the second Sunday in March
- dst_start = self._FirstSunday(datetime.datetime(dt.year, 3, 8, 2))
- # 1 am on the first Sunday in November
- dst_end = self._FirstSunday(datetime.datetime(dt.year, 11, 1, 1))
-
- if dst_start <= dt.replace(tzinfo=None) < dst_end:
- return datetime.timedelta(hours=1)
- else:
- return datetime.timedelta(hours=0)
-
- def tzname(self, dt):
- if self.dst(dt) == datetime.timedelta(hours=0):
- return 'PST'
- else:
- return 'PDT'
-
-
-def UtcToPacific(utc_time):
- return datetime.datetime.fromtimestamp(time.mktime(utc_time.timetuple()),
- PacificTzinfo())
-
-
-def PacificToUtc(pacific_time):
- return datetime.datetime.fromtimestamp(time.mktime(pacific_time.timetuple()),
- UtcTzinfo())

Powered by Google App Engine
This is Rietveld 408576698