Is a birth date at least 18 years old?
504696
public function adult($val, $id) {
        if (dater($val) > ( (date('Y') - 18) . date('-m-d H:i:s') )) {
            $this->add($id, 'You must be at least 18 years old.');
            return false;
        }

        return true;
    }
1302882
def check_date (self):
        
        now = datetime.date.today()
        if now.day == 7 and now.month == 1:
            msg = _("Happy birthday for LinkChecker, I'm %d years old today!")
            self.comment(msg % (now.year - 2000))
268495
def age(self):
    """"""
    # TODO(user) move up to AFF4Object after some analysis of how .age is
    # used in the codebase.
    aff4_type = self.Get(self.Schema.TYPE)

    if aff4_type:
      return aff4_type.age
    else:
      # If there is no type attribute yet, we have only just been created and
      # not flushed yet, so just set timestamp to now.
      return rdfvalue.RDFDatetime.Now()
766829
def is_year(self):
        """"""
        dt = DATA_TYPES['year']
        if dt['min'] and dt['max']:
            if type(self.data) is dt['type'] and dt['min'] < self.data < dt['max']:
                self.type = 'year'.upper()
                self.len = None
                return True
110906
def _reduce_age(self, now):
        
        if self.max_age:
            keys = [
                key for key, value in iteritems(self.data)
                if now - value['date'] > self.max_age
            ]
            for key in keys:
                del self.data[key]
940019
def get_age(Rec, sitekey, keybase, Ages, DefaultAge):
    
    site = Rec[sitekey]
    gotone = 0
    if len(Ages) > 0:
        for agerec in Ages:
            if agerec["er_site_name"] == site:
                if "age" in list(agerec.keys()) and agerec["age"] != "":
                    Rec[keybase + "age"] = agerec["age"]
                    gotone = 1
                if "age_unit" in list(agerec.keys()):
                    Rec[keybase + "age_unit"] = agerec["age_unit"]
                if "age_sigma" in list(agerec.keys()):
                    Rec[keybase + "age_sigma"] = agerec["age_sigma"]
    if gotone == 0 and len(DefaultAge) > 1:
        sigma = 0.5 * (float(DefaultAge[1]) - float(DefaultAge[0]))
        age = float(DefaultAge[0]) + sigma
        Rec[keybase + "age"] = '%10.4e' % (age)
        Rec[keybase + "age_sigma"] = '%10.4e' % (sigma)
        Rec[keybase + "age_unit"] = DefaultAge[2]
    return Rec
732831
def age(self, now=None):
        
        if not self.time_created:
            return None
        if now is None:
            now = datetime.utcnow()
        return (now - self.time_created).seconds
1143410
def isValid(self):
        
        today = DateTime()
        expiry_date = self.getExpiryDate()
        if expiry_date and today > expiry_date:
            return False
        # TODO: Do We really need ExpiryDate + DateExpired? Any difference?
        date_expired = self.getDateExpired()
        if date_expired and today > date_expired:
            return False

        date_disposed = self.getDateDisposed()
        if date_disposed and today > date_disposed:
            return False

        return True
257883
def max_age(self):
        
        value = defines.OptionRegistry.MAX_AGE.default
        for option in self.options:
            if option.number == defines.OptionRegistry.MAX_AGE.number:
                value = int(option.value)
        return value
139429
def birthdate
      month_data_element = bio_document.at("td.label[text()*='Date of Birth']").
          next_element.first_element_child
      date_month = month_data_element.inner_text.strip rescue ""
      year = month_data_element.next_element.inner_text.strip rescue ""
      Date.parse("#{date_month} #{year}") rescue nil
    end
1175468
function _handleSelectYear(oEvent){

		var oFocusedDate = new UniversalDate(this._getFocusedDate().getTime());
		var oYearPicker = this.getAggregation("yearPicker");
		var oDate = CalendarUtils._createUniversalUTCDate(oYearPicker.getDate());
		var iMonth = oFocusedDate.getUTCMonth();

		oDate.setUTCMonth(oFocusedDate.getUTCMonth(), oFocusedDate.getUTCDate()); // to keep day and month stable also for islamic date
		oDate.setUTCHours(oFocusedDate.getUTCHours());
		oDate.setUTCMinutes(oFocusedDate.getUTCMinutes());
		oFocusedDate = oDate;

		if (iMonth != oFocusedDate.getUTCMonth() ) {
			// day did not exist in this year (29. Feb) -> go to last day of month
			oFocusedDate.setUTCDate(0);
		}

		_focusDate.call(this, oFocusedDate, true);

		_hideYearPicker.call(this);

	}
984436
def legal_date(year, month, day):
    ''''''
    daysinmonth = month_length(year, month)

    if not (0 < day <= daysinmonth):
        raise ValueError("Month {} doesn't have a day {}".format(month, day))

    return True
1132564
def users_with_birthday(self, month, day):
        """"""

        users = User.objects.filter(properties___birthday__month=month, properties___birthday__day=day)
        results = []
        for user in users:
            # TODO: permissions system
            results.append(user)

        return results
1141629
private boolean isBPDExpired() {
        Map<String, String> bpd = passport.getBPD();
        log.info("[BPD] max age: " + maxAge + " days");

        long maxMillis = -1L;
        try {
            int days = Integer.parseInt(maxAge);
            if (days == 0) {
                log.info("[BPD] auto-expiry disabled");
                return false;
            }

            if (days > 0)
                maxMillis = days * 24 * 60 * 60 * 1000L;
        } catch (NumberFormatException e) {
            log.error(e.getMessage(), e);
            return false;
        }

        long lastUpdate = 0L;
        if (bpd != null) {
            String lastUpdateProperty = bpd.get(BPD_KEY_LASTUPDATE);
            try {
                lastUpdate = lastUpdateProperty != null ? Long.parseLong(lastUpdateProperty) : lastUpdate;
            } catch (NumberFormatException e) {
                log.error(e.getMessage(), e);
                return false;
            }
            log.info("[BPD] last update: " + (lastUpdate == 0 ? "never" : new Date(lastUpdate)));
        }

        long now = System.currentTimeMillis();
        if (maxMillis < 0 || (now - lastUpdate) > maxMillis) {
            log.info("[BPD] expired, will be updated now");
            return true;
        }

        return false;
    }
1303208
def is_valid(self, max_age=None):
        '''  '''

        if max_age is None:
            max_age = self.cache_max_age

        if os.path.isfile(self.cache_path_cache):
            mod_time = os.path.getmtime(self.cache_path_cache)
            current_time = time()
            if (mod_time + max_age) > current_time:
                return True

        return False
99918
def get_max_age(self):
        '''
        '''

        default_ttl = self.context.config.RESULT_STORAGE_EXPIRATION_SECONDS
        if self.context.request.max_age == 0:
            return self.context.request.max_age

        return default_ttl
139283
public function age($date1, $date2 = null)
    {
        $formatter = new AgeFormatter();

        return $formatter->formatDate($date1, $date2);
    }