當前位置: 首頁>>代碼示例>>Python>>正文


Python pytz.all_timezones_set方法代碼示例

本文整理匯總了Python中pytz.all_timezones_set方法的典型用法代碼示例。如果您正苦於以下問題:Python pytz.all_timezones_set方法的具體用法?Python pytz.all_timezones_set怎麽用?Python pytz.all_timezones_set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pytz的用法示例。


在下文中一共展示了pytz.all_timezones_set方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import pytz [as 別名]
# 或者: from pytz import all_timezones_set [as 別名]
def __init__(self, time_provider=None, config_filepath=None):
        # Time manager
        self.time_provider = time_provider if time_provider else TimeProvider()
        # Set timezone
        set(pytz.all_timezones_set)

        # Load configuration
        self.config = Configuration.from_filepath(config_filepath)

        # Setup the global logger
        self.setup_logging()

        # Init trade services and create the broker interface
        # The Factory is used to create the services from the configuration file
        self.broker = BrokerInterface(BrokerFactory(self.config))

        # Create strategy from the factory class
        self.strategy = StrategyFactory(
            self.config, self.broker
        ).make_from_configuration()

        # Create the market provider
        self.market_provider = MarketProvider(self.config, self.broker) 
開發者ID:ilcardella,項目名稱:TradingBot,代碼行數:25,代碼來源:TradingBot.py

示例2: set_session_timezone

# 需要導入模塊: import pytz [as 別名]
# 或者: from pytz import all_timezones_set [as 別名]
def set_session_timezone(request):
    chosen_timezone = request.POST.get("chosen_timezone")
    response_data = {}
    if chosen_timezone in pytz.all_timezones_set:
        request.session["janeway_timezone"] = chosen_timezone
        status = 200
        response_data['message'] = 'OK'
        logger.debug("Timezone set to %s for this session" % chosen_timezone)
    else:
        status = 404
        response_data['message'] = 'Timezone not found: %s' % chosen_timezone
    response_data = {}

    return HttpResponse(
            content=json.dumps(response_data),
            content_type='application/json',
            status=200,
    ) 
開發者ID:BirkbeckCTP,項目名稱:janeway,代碼行數:20,代碼來源:views.py

示例3: test_belfast

# 需要導入模塊: import pytz [as 別名]
# 或者: from pytz import all_timezones_set [as 別名]
def test_belfast(self):
        # Belfast uses London time.
        self.assertTrue('Europe/Belfast' in pytz.all_timezones_set)
        self.assertFalse('Europe/Belfast' in pytz.common_timezones)
        self.assertFalse('Europe/Belfast' in pytz.common_timezones_set) 
開發者ID:Schibum,項目名稱:sndlatr,代碼行數:7,代碼來源:test_tzinfo.py

示例4: _get_localzone

# 需要導入模塊: import pytz [as 別名]
# 或者: from pytz import all_timezones_set [as 別名]
def _get_localzone():
    pipe = subprocess.Popen(
        "systemsetup -gettimezone",
        shell=True,
        stderr=subprocess.PIPE,
        stdout=subprocess.PIPE
    )
    tzname = pipe.stdout.read().replace(b'Time Zone: ', b'').strip()

    if not tzname or tzname not in pytz.all_timezones_set:
        # link will be something like /usr/share/zoneinfo/America/Los_Angeles.
        link = os.readlink("/etc/localtime")
        tzname = link[link.rfind("zoneinfo/") + 9:]
    return pytz.timezone(tzname) 
開發者ID:taxigps,項目名稱:xbmc-addons-chinese,代碼行數:16,代碼來源:darwin.py

示例5: _get_localzone

# 需要導入模塊: import pytz [as 別名]
# 或者: from pytz import all_timezones_set [as 別名]
def _get_localzone(_root='/'):
    with Popen(
        "systemsetup -gettimezone",
        shell=True,
        stderr=subprocess.PIPE,
        stdout=subprocess.PIPE
    ) as pipe:
        tzname = pipe.stdout.read().replace(b'Time Zone: ', b'').strip()

    if not tzname or tzname not in pytz.all_timezones_set:
        # link will be something like /usr/share/zoneinfo/America/Los_Angeles.
        link = os.readlink(os.path.join(_root, "etc/localtime"))
        tzname = link[link.rfind("zoneinfo/") + 9:]

    return pytz.timezone(tzname) 
開發者ID:wakatime,項目名稱:komodo-wakatime,代碼行數:17,代碼來源:darwin.py

示例6: generate_meeting_data

# 需要導入模塊: import pytz [as 別名]
# 或者: from pytz import all_timezones_set [as 別名]
def generate_meeting_data(self):
        """Generates partial XML that is used to create a meeting"""
        meeting_password = self.opts.get("meeting_password")
        meeting_name = self.opts.get("meeting_name")
        meeting_agenda = self.opts.get("meeting_agenda")

        timezone_info = self.get_timezone_info()
        if type(timezone_info.get("id")) is int and timezone_info.get("id") is 0:
            raise FunctionError(timezone_info.get("reason", "unknown reason"))

        utc_offset = datetime.timedelta(hours=timezone_info["gmt_hour"], minutes=timezone_info["gmt_minute"])
        now = datetime.datetime.now(pytz.utc)

        timezones_with_offset = list({tz for tz in map(pytz.timezone, pytz.all_timezones_set)
                                      if now.astimezone(tz).utcoffset() == utc_offset})
        if self.meeting_start_time is None:
            time = datetime.datetime.now(tz=timezones_with_offset[0])
            duration = DEFAULT_MEETING_LENGTH
        else:
            time = datetime.datetime.fromtimestamp(self.meeting_start_time/1000, tz=timezones_with_offset[0])
            if self.meeting_end_time:
                duration = int((self.meeting_end_time/1000 - self.meeting_start_time/1000)/60)
            else:
                duration = DEFAULT_MEETING_LENGTH
        meeting_time = time.strftime("%m/%d/%Y %H:%M:%S")

        xml = """<accessControl>
        <meetingPassword>{}</meetingPassword>
        </accessControl>
        <metaData>
        <confName>{}</confName>
        <agenda>{}</agenda>
        </metaData>
        <schedule>
        <startDate>{}</startDate>
        <duration>{}</duration>
        <timeZoneID>{}</timeZoneID>
        </schedule>""".format(meeting_password, meeting_name, meeting_agenda, meeting_time, duration,
                              timezone_info.get("id"))

        return xml 
開發者ID:ibmresilient,項目名稱:resilient-community-apps,代碼行數:43,代碼來源:cisco_api.py


注:本文中的pytz.all_timezones_set方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。