Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Moved PacificTimezone class to separate module.

  • Loading branch information...
commit 13ece96a74dec8970c2786fb1f12f4c4150031a4 1 parent 41dbc78
@davehunt davehunt authored
Showing with 42 additions and 34 deletions.
  1. +2 −34 mozdownload/scraper.py
  2. +40 −0 mozdownload/timezones.py
View
36 mozdownload/scraper.py
@@ -5,7 +5,7 @@
"""Module to handle downloads for different types of Firefox and Thunderbird builds."""
-from datetime import datetime, tzinfo, timedelta
+from datetime import datetime
import os
import re
import sys
@@ -14,6 +14,7 @@
import mozinfo
from parser import DirectoryParser
+from timezones import PacificTimezone
# Base URL for the path to all builds
@@ -607,36 +608,3 @@ def platform_regex(self):
'win64': 'win64'}
return PLATFORM_FRAGMENTS[self.platform]
-
-
-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)
View
40 mozdownload/timezones.py
@@ -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)
Please sign in to comment.
Something went wrong with that request. Please try again.