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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/mozdownload/mozdownload/scraper.py ('k') | third_party/mozdownload/setup.cfg » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5 """Module for providing specific timezones"""
6
7 from datetime import datetime, timedelta, tzinfo
8
9
10 class PacificTimezone(tzinfo):
11 """Class to set the timezone to PST/PDT and automatically adjusts
12 for daylight saving.
13 """
14
15 def utcoffset(self, dt):
16 return timedelta(hours=-8) + self.dst(dt)
17
18
19 def tzname(self, dt):
20 return "Pacific"
21
22
23 def dst(self, dt):
24 # Daylight saving starts on the second Sunday of March at 2AM standard
25 dst_start_date = self.first_sunday(dt.year, 3) + timedelta(days=7) \
26 + timedelta(hours=2)
27 # Daylight saving ends on the first Sunday of November at 2AM standard
28 dst_end_date = self.first_sunday(dt.year, 11) + timedelta(hours=2)
29
30 if dst_start_date <= dt.replace(tzinfo=None) < dst_end_date:
31 return timedelta(hours=1)
32 else:
33 return timedelta(0)
34
35
36 def first_sunday(self, year, month):
37 date = datetime(year, month, 1, 0)
38 days_until_sunday = 6 - date.weekday()
39
40 return date + timedelta(days=days_until_sunday)
OLDNEW
« 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