本文整理汇总了Python中pytz.country_timezones方法的典型用法代码示例。如果您正苦于以下问题:Python pytz.country_timezones方法的具体用法?Python pytz.country_timezones怎么用?Python pytz.country_timezones使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pytz
的用法示例。
在下文中一共展示了pytz.country_timezones方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_fuso_horaro
# 需要导入模块: import pytz [as 别名]
# 或者: from pytz import country_timezones [as 别名]
def set_fuso_horaro(self, novo_valor):
if novo_valor in pytz.country_timezones['br']:
self._fuso_horario = pytz.timezone(novo_valor)
#
# Nos valores abaixo, não entendi ainda até agora, mas para o resultado
# correto é preciso usar GMT+ (mais), não (menos) como seria de se
# esperar...
#
elif novo_valor == '-04:00' or novo_valor == '-0400':
self._fuso_horario = pytz.timezone('Etc/GMT+4')
elif novo_valor == '-03:00' or novo_valor == '-0300':
self._fuso_horario = pytz.timezone('Etc/GMT+3')
elif novo_valor == '-02:00' or novo_valor == '-0200':
self._fuso_horario = pytz.timezone('Etc/GMT+2')
elif novo_valor == '-01:00' or novo_valor == '-0100':
self._fuso_horario = pytz.timezone('Etc/GMT+1')
示例2: timezone_country
# 需要导入模块: import pytz [as 别名]
# 或者: from pytz import country_timezones [as 别名]
def timezone_country(self, ctx, country):
"""Commonly used timezones with ISO 3166 country codes.
Example:
[p]timezone country nz
"""
timezones = pytz.country_timezones(country)
if not len(timezones):
await self.bot.say(
"{} does not appear to be a "
"valid ISO 3166 country code.".format(country))
return
name = pytz.country_names[country]
await self.bot.say(
"Commonly used timezones in {}: {}.".format(
name, ", ".join(timezones)))
示例3: resources
# 需要导入模块: import pytz [as 别名]
# 或者: from pytz import country_timezones [as 别名]
def resources(self):
def _append(x, y):
return x + y
yield ew.JSScript('''
var $allTimezones = $("#tz").clone();
var $t = {};
''' +
reduce(_append, [
'$t["' + el + '"] = ' + str([name.encode('utf-8')
for name in country_timezones[el]]) + ";\n"
for el in country_timezones]) + '''
function selectTimezone($country){
if($country == " "){
$("#tz").replaceWith($allTimezones);
}
else{
$("#tz option:gt(0)").remove();
$.each($t[$country], function(index, value){
$("#tz").append($("<option></option>").attr("value", value).text(value))
})
}
}''')
示例4: convert_dt_to_timezone
# 需要导入模块: import pytz [as 别名]
# 或者: from pytz import country_timezones [as 别名]
def convert_dt_to_timezone(row):
try:
timezone = pytz.country_timezones[row["platform"]]
except:
timezone = [timezones[row["platform"]]]
return row["datetime"].to(timezone[0])
示例5: get_time_zone
# 需要导入模块: import pytz [as 别名]
# 或者: from pytz import country_timezones [as 别名]
def get_time_zone(country_code):
"""
Return time zone for country.
"""
try:
return country_timezones[country_code][0]
except KeyError:
return None
示例6: timezone4loc
# 需要导入模块: import pytz [as 别名]
# 或者: from pytz import country_timezones [as 别名]
def timezone4loc(loc, fallback=None):
""" Returns timezone string given a tuple of coordinates.
Fallback argument should be an ISO country code."""
if loc:
return tzwhere_singleton().tzNameAt(loc[0], loc[1], forceTZ=True)
if fallback and fallback in country_timezones:
return country_timezones[fallback][0]
return None