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


Python ServerTime.strftime方法代碼示例

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


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

示例1: template_context

# 需要導入模塊: from corehq.util.timezones.conversions import ServerTime [as 別名]
# 或者: from corehq.util.timezones.conversions.ServerTime import strftime [as 別名]
 def template_context(self):
     event = self.messaging_event
     date = ServerTime(event.date).user_time(self.timezone).done()
     return {
         'messaging_event_date': date.strftime(SERVER_DATETIME_FORMAT),
         'messaging_event_type': self.get_source_display(event, display_only=True),
     }
開發者ID:ansarbek,項目名稱:commcare-hq,代碼行數:9,代碼來源:sms.py

示例2: _update_tech_issue_for_escalation

# 需要導入模塊: from corehq.util.timezones.conversions import ServerTime [as 別名]
# 或者: from corehq.util.timezones.conversions.ServerTime import strftime [as 別名]
def _update_tech_issue_for_escalation(case, escalated_ticket_level):
    today = ServerTime(datetime.utcnow()).user_time(pytz.timezone('Asia/Kolkata')).done().date()

    return update_case(
        case.domain,
        case.case_id,
        case_properties={
            'ticket_level': escalated_ticket_level,
            'change_in_level': '1',
            'touch_case_date': today.strftime('%Y-%m-%d'),
        },
        close=False,
        xmlns=AUTO_UPDATE_XMLNS,
        device_id=__name__ + "._update_tech_issue_for_escalation",
    )
開發者ID:kkrampa,項目名稱:commcare-hq,代碼行數:17,代碼來源:custom_actions.py

示例3: _fmt_date

# 需要導入模塊: from corehq.util.timezones.conversions import ServerTime [as 別名]
# 或者: from corehq.util.timezones.conversions.ServerTime import strftime [as 別名]
 def _fmt_date(somedate):
     time = ServerTime(somedate).user_time(self.timezone).done()
     return time.strftime(SERVER_DATETIME_FORMAT)
開發者ID:ansarbek,項目名稱:commcare-hq,代碼行數:5,代碼來源:reports.py

示例4: OutboundDailyCounter

# 需要導入模塊: from corehq.util.timezones.conversions import ServerTime [as 別名]
# 或者: from corehq.util.timezones.conversions.ServerTime import strftime [as 別名]
class OutboundDailyCounter(object):

    def __init__(self, domain_object=None):
        self.domain_object = domain_object

        if domain_object:
            self.date = ServerTime(datetime.utcnow()).user_time(domain_object.get_default_timezone()).done().date()
        else:
            self.date = datetime.utcnow().date()

        self.key = 'outbound-daily-count-for-%s-%s' % (
            domain_object.name if domain_object else '',
            self.date.strftime('%Y-%m-%d')
        )

        # We need access to the raw redis client because calling incr on
        # a django_redis RedisCache object raises an error if the key
        # doesn't exist.
        self.client = get_redis_client().client.get_client()

    def increment(self):
        # If the key doesn't exist, redis will set it to 0 and then increment.
        value = self.client.incr(self.key)

        # If it's the first time we're calling incr, set the key's expiration
        if value == 1:
            self.client.expire(self.key, 24 * 60 * 60)

        return value

    def decrement(self):
        return self.client.decr(self.key)

    @property
    def current_usage(self):
        return self.client.get(self.key) or 0

    @property
    def daily_limit(self):
        if self.domain_object:
            return self.domain_object.get_daily_outbound_sms_limit()
        else:
            # If the message isn't tied to a domain, still impose a limit.
            # Outbound messages not tied to a domain can happen when unregistered
            # contacts opt in or out from a gateway.
            return 10000

    def can_send_outbound_sms(self, queued_sms):
        """
        Returns False if the outbound daily limit has been exceeded.
        """
        value = self.increment()

        if value > self.daily_limit:
            # Delay processing by an hour so that in case the
            # limit gets increased within the same day, we start
            # processing the backlog right away.
            self.decrement()
            delay_processing(queued_sms, 60)

            # Log the fact that we reached this limit
            DailyOutboundSMSLimitReached.create_for_domain_and_date(
                self.domain_object.name if self.domain_object else '',
                self.date
            )
            return False

        return True
開發者ID:dimagi,項目名稱:commcare-hq,代碼行數:70,代碼來源:tasks.py

示例5: server_to_user_time

# 需要導入模塊: from corehq.util.timezones.conversions import ServerTime [as 別名]
# 或者: from corehq.util.timezones.conversions.ServerTime import strftime [as 別名]
def server_to_user_time(server_time, timezone):
    user_time = ServerTime(server_time).user_time(timezone).done()
    return user_time.strftime("%Y-%m-%d %H:%M")
開發者ID:dimagi,項目名稱:commcare-hq,代碼行數:5,代碼來源:util.py

示例6: format_timestamp

# 需要導入模塊: from corehq.util.timezones.conversions import ServerTime [as 別名]
# 或者: from corehq.util.timezones.conversions.ServerTime import strftime [as 別名]
 def format_timestamp(self, utc_timestamp):
     ist_timestamp = ServerTime(utc_timestamp).user_time(self.timezone).done()
     return ist_timestamp.strftime('%Y-%m-%d %H:%M:%S')
開發者ID:kkrampa,項目名稱:commcare-hq,代碼行數:5,代碼來源:get_icds_sms_export.py


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