本文整理匯總了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