Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pygeoip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
pygeoip
Commits
e957f76c
Commit
e957f76c
authored
Jul 22, 2013
by
William Tisäter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move time zone function to top of file for easier access
parent
8b91b1d8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
16 deletions
+22
-16
pygeoip/timezone.py
+22
-16
No files found.
pygeoip/timezone.py
View file @
e957f76c
...
...
@@ -21,9 +21,29 @@ You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/lgpl.txt>.
"""
__all__
=
[
'time_zone_by_country_and_region'
]
_country
=
{
def
time_zone_by_country_and_region
(
country_code
,
region_code
=
None
):
"""
Get time zone from country code and region code.
@param country_code: Country code
@type country_code: str
@param region_code: Region code
@type region_code: str
@return: Time zone
@rtype: str
"""
timezone
=
country_dict
.
get
(
country_code
)
if
not
timezone
:
return
None
if
isinstance
(
timezone
,
str
):
return
timezone
return
timezone
.
get
(
region_code
)
country_dict
=
{
'AD'
:
'Europe/Andorra'
,
'AE'
:
'Asia/Dubai'
,
'AF'
:
'Asia/Kabul'
,
...
...
@@ -742,17 +762,3 @@ _country = {
'ZM'
:
'Africa/Lusaka'
,
'ZW'
:
'Africa/Harare'
}
def
time_zone_by_country_and_region
(
country_code
,
region_name
=
None
):
timezones
=
_country
.
get
(
country_code
)
if
not
timezones
:
return
None
if
isinstance
(
timezones
,
str
):
return
timezones
if
not
region_name
:
return
None
return
timezones
.
get
(
region_name
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment