Date before a certificate should be renewed

    :param name: Common Name of the certificate (DNS name of certificate)
    :param window: days before expiry date to renew
    :return datetime object of first renewal date
341609
def _renew_by(name, window=None):
    '''
    
    '''
    expiry = _expires(name)
    if window is not None:
        expiry = expiry - datetime.timedelta(days=window)

    return expiry
892556
def date(options = {})
      non_relative_prefix = options[:non_relative_prefix] || "on "
      if interrogator.today?
        result = "today"
      elsif interrogator.yesterday?
        result = "yesterday"
      elsif interrogator.tomorrow?
        result = "tomorrow"
      elsif @context == :future && interrogator.next_x_days?(6)
        result = non_relative_prefix + name_of_day
      elsif @context == :future && interrogator.next_week?
        result = "next #{name_of_day}"
      elsif @context == :past && interrogator.last_x_days?(6)
        result = non_relative_prefix + name_of_day
      elsif @context == :past && interrogator.last_x_days?(12)
        result = "last #{name_of_day}"
      elsif @context == :past && interrogator.next_x_days?(6)
        result = "next #{name_of_day}"
      else
        result = non_relative_prefix + "#{name_of_day} #{day_of_month} #{name_of_month}"
        result += " #{@time.year}" if include_year_in_dates?
        result
      end

      unless options[:capitalize] == false
        result[0] = result[0].upcase
      end

      result
    end
134669
def get_date(self):
        
        if self.safe_type == EsaSafeType.OLD_TYPE:
            name = self.product_id.split('_')[-2]
            date = [name[1:5], name[5:7], name[7:9]]
        else:
            name = self.product_id.split('_')[2]
            date = [name[:4], name[4:6], name[6:8]]
        return '-'.join(date_part.lstrip('0') for date_part in date)
1191788
async def expire(self, name, time):
        
        if isinstance(time, datetime.timedelta):
            time = time.seconds + time.days * 24 * 3600
        return await self.execute_command('EXPIRE', name, time)
1334731
function(name, value, expires, path, domain, secure) {
		var d = new Date();

		if ( typeof(expires) == 'object' && expires.toGMTString ) {
			expires = expires.toGMTString();
		} else if ( parseInt(expires, 10) ) {
			d.setTime( d.getTime() + ( parseInt(expires, 10) * 1000 ) ); // time must be in miliseconds
			expires = d.toGMTString();
		} else {
			expires = '';
		}

		document.cookie = name + "=" + encodeURIComponent(value) +
			((expires) ? "; expires=" + expires : "") +
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			((secure) ? "; secure" : "");
	}
1158031
def namedb_get_name(cur, name, current_block, include_expired=False, include_history=True, only_registered=True):
    

    if not include_expired:

        unexpired_fragment, unexpired_args = namedb_select_where_unexpired_names(current_block, only_registered=only_registered)
        select_query = "SELECT name_records.* FROM name_records JOIN namespaces ON name_records.namespace_id = namespaces.namespace_id " + \
                       "WHERE name = ? AND " + unexpired_fragment + ";"
        args = (name, ) + unexpired_args

    else:
        select_query = "SELECT * FROM name_records WHERE name = ?;"
        args = (name,)

    # log.debug(namedb_format_query(select_query, args))

    name_rows = namedb_query_execute( cur, select_query, args )
    name_row = name_rows.fetchone()
    if name_row is None:
        # no such name
        return None 

    name_rec = {}
    name_rec.update( name_row )
    
    if include_history:
        name_history = namedb_get_history( cur, name )
        name_rec['history'] = name_history

    return name_rec
757080
def set_cookie(self, name: str, value: str, *,
                   expires: Optional[str]=None,
                   domain: Optional[str]=None,
                   max_age: Optional[Union[int, str]]=None,
                   path: str='/',
                   secure: Optional[str]=None,
                   httponly: Optional[str]=None,
                   version: Optional[str]=None) -> None:
        

        old = self._cookies.get(name)
        if old is not None and old.coded_value == '':
            # deleted cookie
            self._cookies.pop(name, None)

        self._cookies[name] = value
        c = self._cookies[name]

        if expires is not None:
            c['expires'] = expires
        elif c.get('expires') == 'Thu, 01 Jan 1970 00:00:00 GMT':
            del c['expires']

        if domain is not None:
            c['domain'] = domain

        if max_age is not None:
            c['max-age'] = str(max_age)
        elif 'max-age' in c:
            del c['max-age']

        c['path'] = path

        if secure is not None:
            c['secure'] = secure
        if httponly is not None:
            c['httponly'] = httponly
        if version is not None:
            c['version'] = version
1207948
def expireat(self, name, when):
        
        if isinstance(when, datetime.datetime):
            when = int(mod_time.mktime(when.timetuple()))
        return self.execute_command('EXPIREAT', name, when)
1105396
function (cookieV1) {
        return {
            expires: (new Date(cookieV1.expirationDate * 1000)).toString(),
            hostOnly: cookieV1.hostOnly,
            httpOnly: cookieV1.httpOnly,
            domain: cookieV1.domain,
            path: cookieV1.path,
            secure: cookieV1.secure,
            session: cookieV1.session,
            value: cookieV1.value,
            key: cookieV1.name
        };
    }
185383
def get_nameday(self, month=None, day=None):
        """"""
        if month is None:
            month = datetime.now().month
        if day is None:
            day = datetime.now().day
        return self.NAMEDAYS[month-1][day-1]
793641
function setEndDate($date)
    {
        /*
          To indicate that a certificate has no well-defined expiration date,
          the notAfter SHOULD be assigned the GeneralizedTime value of
          99991231235959Z.

          -- http://tools.ietf.org/html/rfc5280#section-4.1.2.5
        */
        if (strtolower($date) == 'lifetime') {
            $temp = '99991231235959Z';
            $asn1 = new File_ASN1();
            $temp = chr(FILE_ASN1_TYPE_GENERALIZED_TIME) . $asn1->_encodeLength(strlen($temp)) . $temp;
            $this->endDate = new File_ASN1_Element($temp);
        } else {
            $this->endDate = @date('D, d M Y H:i:s O', @strtotime($date));
        }
    }
534326
def before_start(self, when=None):
        
        if when is None:
            when = datetime.now()

        return self._val[0] > when
970841
function setEndDate($date)
    {
        /*
          To indicate that a certificate has no well-defined expiration date,
          the notAfter SHOULD be assigned the GeneralizedTime value of
          99991231235959Z.

          -- http://tools.ietf.org/html/rfc5280#section-4.1.2.5
        */
        if (strtolower($date) == 'lifetime') {
            $temp = '99991231235959Z';
            $asn1 = new ASN1();
            $temp = chr(ASN1::TYPE_GENERALIZED_TIME) . $asn1->_encodeLength(strlen($temp)) . $temp;
            $this->endDate = new Element($temp);
        } else {
            if (!is_object($date) || !is_a($date, 'DateTime')) {
                $date = new DateTime($date, new DateTimeZone(@date_default_timezone_get()));
            }

            $this->endDate = $date->format('D, d M Y H:i:s O');
        }
    }
237587
def certify_date(value, required=True):
    
    if certify_required(
        value=value,
        required=required,
    ):
        return

    if not isinstance(value, date):
        raise CertifierTypeError(
            message="expected timestamp (date∂), but value is of type {cls!r}".format(
                cls=value.__class__.__name__),
            value=value,
            required=required,
        )
554323
function (t, timerName) {
            if (this.enabled) {
                var id = _.uniqueId('jt');
                this._startDate[id] = t || (+new Date());
                if (console.profile && timerName) {
                    this._timerConsoleName[id] = timerName;
                    console.profile(timerName);
                }
                return id;
            }
        }
1085250
private boolean isCertExpired(X509Certificate cert) {
		if (cert != null && cert.getNotAfter().before(new Date())) {
			return true;
		}
		return false;
	}
590098
def load_name_info(self, db, name_record):
        
        name = str(name_record['name'])
        name_record = self.sanitize_rec(name_record)

        namespace_id = get_namespace_from_name(name)
        namespace_record = db.get_namespace(namespace_id, include_history=False)
        if namespace_record is None:
            namespace_record = db.get_namespace_reveal(namespace_id, include_history=False)

        if namespace_record is None:
            # name can't exist (this can be arrived at if we're resolving a DID)
            return None

        # when does this name expire (if it expires)?
        if namespace_record['lifetime'] != NAMESPACE_LIFE_INFINITE:
            deadlines = BlockstackDB.get_name_deadlines(name_record, namespace_record, db.lastblock)
            if deadlines is not None:
                name_record['expire_block'] = deadlines['expire_block']
                name_record['renewal_deadline'] = deadlines['renewal_deadline']
            else:
                # only possible if namespace is not yet ready
                name_record['expire_block'] = -1
                name_record['renewal_deadline'] = -1

        else:
            name_record['expire_block'] = -1
            name_record['renewal_deadline'] = -1

        if name_record['expire_block'] > 0 and name_record['expire_block'] <= db.lastblock:
            name_record['expired'] = True
        else:
            name_record['expired'] = False

        # try to get the zonefile as well 
        if 'value_hash' in name_record and name_record['value_hash'] is not None:
            conf = get_blockstack_opts()
            if is_atlas_enabled(conf):
                zfdata = self.get_zonefile_data(name_record['value_hash'], conf['zonefiles'])
                if zfdata is not None:
                    zfdata = base64.b64encode(zfdata)
                    name_record['zonefile'] = zfdata

        return name_record