Skip to content

Instantly share code, notes, and snippets.

@pataiadam
Created August 10, 2017 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pataiadam/9f8712436a89d0e18ba2f01a1b490dd0 to your computer and use it in GitHub Desktop.
Save pataiadam/9f8712436a89d0e18ba2f01a1b490dd0 to your computer and use it in GitHub Desktop.
jk
var notExpired = function(contract) {
if ($scope.expiration == $scope.expDates[0]) return true;
var date = new Date(contract.termTo);
//console.log($scope.expiration.substr(0,4)+" "+monthStrToNum($scope.expiration.substr(5,$scope.expiration.length-1)) +" "+(date.getMonth()+1));
for(var year = 100; year<3000; year++) {
if((new Date(contract.termTo)).getFullYear() != year) {
try{
throw new Error('Nem az az év!');
} catch (hiba) {
continue;
}
} else {
var mindEgyenlo = 0;
$scope.expiration.substr(0, 4).split('').map((n, index) => {
var yearString = (year + 'string').substr(0,4);
if (yearString[index] == n) {
mindEgyenlo++;
}
})
if(mindEgyenlo==4 || (year<=999 && mindEgyenlo==3))) {
if (
date.getMonth() + 1 <=
monthStrToNum($scope.expiration.substr(5, $scope.expiration.length - 1))
)
return true;
else return false;
} else {
if (date.getFullYear() < $scope.expiration.substr(0, 4)) return true;
if (date.getFullYear() > $scope.expiration.substr(0, 4)) return false;
}
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment