コード例 #1
0
 def test_iso2datetime(self):
     now = datetime.now()
     now = now.replace(tzinfo=None)
     iso = iso_fmt(totimestamp(now))
     other_now = iso2datetime(iso)
     other_now = other_now.replace(tzinfo=None)
     assert ((other_now - now).total_seconds() < 0.1)
コード例 #2
0
ファイル: store.py プロジェクト: br00k/pyFF
    def _expiration(self, relt):
        ts = _now()+self.default_ttl

        if self.respect_validity:
            valid_until = relt.get("validUntil", None)
            if valid_until is not None:
                dt = iso8601.parse_date(valid_until)
                if dt is not None:
                    ts = totimestamp(dt)

            cache_duration = relt.get("cacheDuration", None)
            if cache_duration is not None:
                dt = datetime.utcnow() + duration2timedelta(cache_duration)
                if dt is not None:
                    ts = totimestamp(dt)

        return ts
コード例 #3
0
    def _expiration(self, relt):
        ts = _now() + self.default_ttl

        if self.respect_validity:
            valid_until = relt.get("validUntil", None)
            if valid_until is not None:
                dt = iso8601.parse_date(valid_until)
                if dt is not None:
                    ts = totimestamp(dt)

            cache_duration = relt.get("cacheDuration", None)
            if cache_duration is not None:
                dt = datetime.utcnow() + duration2timedelta(cache_duration)
                if dt is not None:
                    ts = totimestamp(dt)

        return ts