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

Unified Diff: third_party/mozdownload/mozdownload/timezones.py

Issue 108313011: Adding mozilla libraries required by Firefox interop test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/
Patch Set: Created 7 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
« no previous file with comments | « third_party/mozdownload/mozdownload/scraper.py ('k') | third_party/mozdownload/setup.cfg » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/mozdownload/mozdownload/timezones.py
===================================================================
--- third_party/mozdownload/mozdownload/timezones.py (revision 0)
+++ third_party/mozdownload/mozdownload/timezones.py (revision 0)
@@ -0,0 +1,40 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+"""Module for providing specific timezones"""
+
+from datetime import datetime, timedelta, tzinfo
+
+
+class PacificTimezone(tzinfo):
+ """Class to set the timezone to PST/PDT and automatically adjusts
+ for daylight saving.
+ """
+
+ def utcoffset(self, dt):
+ return timedelta(hours=-8) + self.dst(dt)
+
+
+ def tzname(self, dt):
+ return "Pacific"
+
+
+ def dst(self, dt):
+ # Daylight saving starts on the second Sunday of March at 2AM standard
+ dst_start_date = self.first_sunday(dt.year, 3) + timedelta(days=7) \
+ + timedelta(hours=2)
+ # Daylight saving ends on the first Sunday of November at 2AM standard
+ dst_end_date = self.first_sunday(dt.year, 11) + timedelta(hours=2)
+
+ if dst_start_date <= dt.replace(tzinfo=None) < dst_end_date:
+ return timedelta(hours=1)
+ else:
+ return timedelta(0)
+
+
+ def first_sunday(self, year, month):
+ date = datetime(year, month, 1, 0)
+ days_until_sunday = 6 - date.weekday()
+
+ return date + timedelta(days=days_until_sunday)
Property changes on: third_party/mozdownload/mozdownload/timezones.py
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « third_party/mozdownload/mozdownload/scraper.py ('k') | third_party/mozdownload/setup.cfg » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698