

function nicController($scope) {
    var id = "";
    var month = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

    function getYear() {
        return (1900 + Number(id.substring(0, 2)));
    }

    function getDays() {
        var d = id.substring(2, 5);
        if (d > 500) {
            return (d - 500);
        } else {
            return d;
        }
    }

    function getMonthAndDate() {
        var mo = 0, da = 0;
        var days = getDays();

        for (var i = 0; i < month.length; i++) {
            if (days < month[i]) {
                mo = i + 1;
                da = days;
                break;
            } else {
                days = days - month[i];
            }
        }
       return { month:mo ,date: + da};

    }

    function getSex() {
        var M = "Male", F = "Female";
        var d = id.substring(2, 5);
        if (d > 500) {
            return 'F';
        } else {
            return 'M';
        }
    }


    $scope.findNIC = function () {
        localStorage.nic=$scope.NIC;
        localStorage.name=$scope.name;
        window.location = "result.html";
    }

    $scope.getValues = function(){
        id = localStorage.nic;
        $scope.dob=( getYear() + "-" + getMonthAndDate().month + "-" + getMonthAndDate().date);
        $scope.name=localStorage.name;
        $scope.nic = localStorage.nic;
        $scope.gender = getSex();
    }

//


}