Created
August 10, 2017 18:52
-
-
Save pataiadam/9f8712436a89d0e18ba2f01a1b490dd0 to your computer and use it in GitHub Desktop.
jk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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