Expiry treated as a unix timestamp instead of an offset if expiry is greater than 30 days.

@src https://developer.couchbase.com/documentation/server/4.1/developer-guide/expiry.html
434588
private function normalizeExpiry(int $expiry) : int
    {
        if ($expiry > self::THIRTY_DAYS_IN_SECONDS) {
            return time() + $expiry;
        }

        return $expiry;
    }
205427
def new_expiry(days=DEFAULT_PASTE_LIFETIME_DAYS):
    """"""
    now = delorean.Delorean()
    return now + datetime.timedelta(days=days)
1042632
def add_expiration_postfix(expiration):
    
    if re.match(r'^[1-9][0-9]*$', expiration):
        return expiration + ".0a1"

    if re.match(r'^[1-9][0-9]*\.0$', expiration):
        return expiration + "a1"

    return expiration
26408
function getExpiryDate(store, data) {
        
        var offset;

        if (data.cookie.originalMaxAge) {
            offset = data.cookie.originalMaxAge;
        } else {
            offset = store.sessionTimeOut * 60000;
        }
        
        return offset ? new Date(Date.now() + offset) : null;
    }
1072484
def get_expiration(self):
        
        exp = self._get_int('expiration')
        if exp is not None:
            return datetime.datetime.fromtimestamp(
                exp
            )
        return None
1260551
def _has_expired(self):
        
        expired = False
        if hasattr(self, 'Expiration'):
            now = datetime.datetime.utcnow()
            expiration = datetime.datetime.strptime(self.Expiration, '%Y-%m-%dT%H:%M:%SZ')
            expired = (now >= expiration)
        else:
            raise ValueError("ERROR: Request for expired property, but no Expiration in HIT!")
        return expired
1001120
def _calculate_session_expiry(self, request, user_info):
        """"""
        access_token_expiry_timestamp = self._get_access_token_expiry(request)
        id_token_expiry_timestamp = self._get_id_token_expiry(user_info)
        now_in_seconds = int(time.time())

        # The session length is set to match whichever token expiration time is closer.
        earliest_expiration_timestamp = min(access_token_expiry_timestamp, id_token_expiry_timestamp)
        seconds_until_expiry = earliest_expiration_timestamp - now_in_seconds

        if seconds_until_expiry <= 0:
            raise AuthError('Session expiry time has already passed!')

        return seconds_until_expiry
354955
function (ISO8601Duration) {
            var isValueNegative = (ISO8601Duration.indexOf("-") >= 0),
                indexOfT = ISO8601Duration.indexOf("T"),
                indexOfH = ISO8601Duration.indexOf("H"),
                indexOfM = ISO8601Duration.indexOf("M"),
                indexOfS = ISO8601Duration.indexOf("S"),
                hours,
                minutes,
                seconds,
                durationInMilliseconds;

            if ((indexOfT === -1) || ((indexOfM !== -1) && (indexOfM < indexOfT)) || (ISO8601Duration.indexOf("D") !== -1) || (ISO8601Duration.indexOf("Y") !== -1)) {
                throw new Error("ISO 8601 timestamps including years, months and/or days are not currently supported");
            }

            if (indexOfH === -1) {
                indexOfH = indexOfT;
                hours = 0;
            }
            else {
                hours = parseInt(ISO8601Duration.slice(indexOfT + 1, indexOfH), 10);
            }

            if (indexOfM === -1) {
                indexOfM = indexOfT;
                minutes = 0;
            }
            else {
                minutes = parseInt(ISO8601Duration.slice(indexOfH + 1, indexOfM), 10);
            }

            seconds = parseFloat(ISO8601Duration.slice(indexOfM + 1, indexOfS));

            durationInMilliseconds = parseInt((((((hours * 60) + minutes) * 60) + seconds) * 1000), 10);
            if (isNaN(durationInMilliseconds)){
                durationInMilliseconds = 0;
            }
            if (isValueNegative) {
                durationInMilliseconds = durationInMilliseconds * -1;
            }

            return durationInMilliseconds;
        }
778916
def extend_expiration_date(self, days=KEY_EXPIRATION_DELTA):
        
        delta = timedelta_days(days)
        self.expiration_date = self.expiration_date + delta
        self.save()
1369373
def calculate_expiration(self, token):
        
        if not token:
            return None
        now = datetime.utcnow()
        time_to_live = self.config["expiration"]
        if "exp" not in token:
            return now + timedelta(seconds=time_to_live)
        elif self.config["refresh"]:
            exp = datetime.utcfromtimestamp(token["exp"])
            # 0.5: reduce refresh frequent
            if exp - now < timedelta(seconds=0.5 * time_to_live):
                return now + timedelta(seconds=time_to_live)
        return None
1266492
function() {
    this.creationTime = undefined;
    this.lastModTime = undefined;
    this.lastAccessTime = undefined;
    this.expiryTime = undefined;
    this.expires = undefined;
    this.usageCount = undefined;
    this.locationChanged = new Date();
    Object.preventExtensions(this);
}
1302113
def expires(self):
        
        not_after = self._cert.get_notAfter().decode('ascii')
        return datetime.datetime.strptime(not_after, '%Y%m%d%H%M%SZ').replace(
            tzinfo=datetime.timezone.utc)
688159
function(req, res, user) {
    var jsonWebTokens = waterlock.config.jsonWebTokens || {};
    var expiryUnit = (jsonWebTokens.expiry && jsonWebTokens.expiry.unit) || 'days';
    var expiryLength = (jsonWebTokens.expiry && jsonWebTokens.expiry.length) || 7;
    var expires = moment().add(expiryLength, expiryUnit).valueOf();
    var issued = Date.now();
    user = user || req.session.user;

    var token = jwt.encode({
      iss: user.id + '|' + req.remoteAddress,
      sub: jsonWebTokens.subject,
      aud: jsonWebTokens.audience,
      exp: expires,
      nbf: issued,
      iat: issued,
      jti: uuid.v1()
    }, jsonWebTokens.secret);

    return {
      token: token,
      expires: expires
    };
  }
1791
public static function offset_date($type, $timestamp, $offset = 30)
    {
        if (!$timestamp) {
            $timestamp = time();
        }

        // check whether the timestamp was
        // given as a date string (2016-09-05)
        if(strpos($timestamp, "-") > 0) {
            $timestamp = strtotime($timestamp);
        }

        $offsetCalc = $offset * 24 * 60 * 60; //days in secs

        $offsetTime = null;
        if ($type == 'start') {
            $offsetTime = $timestamp - $offsetCalc;
        } elseif ($type == 'end') {
            $offsetTime = $timestamp + $offsetCalc;
        }

        $str = date('Y-m-d', $offsetTime);
        return $str;
    }
792256
public function calculate_expiry($timestamp) {
        $expiry = null;

        if (isset($this->expiredate)) {
            $expiry = $this->expiredate;
        } else if (isset($this->expireperiod)) {
            $expiry = $timestamp + $this->expireperiod;
        }

        return $expiry;
    }
709424
public void setExpiryTime(long pExpiryTime) {
        long oldEexpiryTime = expiryTime;

        expiryTime = pExpiryTime;

        if (expiryTime < oldEexpiryTime) {
            // Expire now
            nextExpiryTime = 0;
            removeExpiredEntries();
        }
    }
508275
private long calculateExpiryTime(K key, PutOperation<K, V> existing, Operation<K, V> operation, Result<K, V> newValue) {
    if (operation.isExpiryAvailable()) {
      return operation.expirationTime();
    } else {
      try {
        Duration duration;
        if (existing == null) {
          duration = requireNonNull(expiry.getExpiryForCreation(key, newValue.getValue()));
        } else {
          duration = expiry.getExpiryForUpdate(key, existing::getValue, newValue.getValue());
          if (duration == null) {
            return existing.expirationTime();
          }
        }
        if (duration.isNegative()) {
          duration = Duration.ZERO;
        } else if (isExpiryDurationInfinite(duration)) {
          return Long.MAX_VALUE;
        }
        return ExpiryUtils.getExpirationMillis(operation.timeStamp(), duration);
      } catch (Exception ex) {
        LOG.error("Expiry computation caused an exception - Expiry duration will be 0 ", ex);
        return Long.MIN_VALUE;
      }
    }
  }