public function convert($formatOpt = true)
 {
     $year = $this->year;
     $month = $this->month;
     $day = $this->day;
     $bs = Utility::$nepaliDates;
     //Initial english dates
     $init_engYear = 1943;
     $init_engMonth = 4;
     $init_engDay = 14 - 1;
     //Equivalent nepali dates
     $init_nepYear = 2000;
     $init_nepMonth = 1;
     $init_nepDay = 1;
     //Initialization of value
     $totalDays_eng = 0;
     $totalDays_nep = 0;
     $k = 0;
     //Count total number of days interms of year
     for ($i = 0; $i < $year - $init_nepYear; $i++) {
         for ($j = 1; $j <= 12; $j++) {
             $totalDays_nep += $bs[$k][$j];
         }
         $k++;
     }
     //Count total number of days in-terms of month
     for ($j = 1; $j < $month; $j++) {
         $totalDays_nep += $bs[$k][$j];
     }
     //total number days for given nepali date
     $totalDays_nep += $day;
     //now calculating of equivalent english date...
     $general_month = array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
     $leap_month = array(0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
     $weekDay = 4 - 1;
     $a = 0;
     $numDay = 0;
     $totalDays_eng = $init_engDay;
     $m = $init_engMonth;
     $y = $init_engYear;
     while ($totalDays_nep != 0) {
         if (Utility::isLeapYear($y)) {
             $a = $leap_month[$m];
         } else {
             $a = $general_month[$m];
         }
         $totalDays_eng++;
         $weekDay++;
         if ($totalDays_eng > $a) {
             $m++;
             $totalDays_eng = 1;
             if ($m > 12) {
                 $y++;
                 $m = 1;
             }
         }
         if ($weekDay > 7) {
             $weekDay = 1;
         }
         $totalDays_nep--;
     }
     $numDay = $weekDay;
     //storing converted value in array
     $newDate = array();
     $newDate["year"] = $y;
     $newDate["num_month"] = sprintf("%02d", $m);
     $newDate["day"] = sprintf("%02d", $totalDays_eng);
     $newDate["alpha_weekDay"] = Day::getWeekDay($weekDay);
     $newDate["alpha_month"] = EnglishFormat::getMonth($m);
     $newDate["num_weekDay"] = $numDay;
     if ($formatOpt == false) {
         return $newDate;
     }
     $newDate['format'] = $this->format;
     $cDate = Utility::formatResult($newDate);
     return $cDate;
 }
 public function convert($formatOpt = true)
 {
     $year = $this->year;
     $month = $this->month;
     $day = $this->day;
     $bs = Utility::$nepaliDates;
     //English month data.
     $general_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
     $leap_month = array(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
     //Initial values for eng and nep dates
     $init_engYear = 1944;
     $init_nepYear = 2000;
     $init_nepMonth = 9;
     $init_nepDay = 17 - 1;
     //Initialization of values
     $totalDays_eng = 0;
     //Count total no of days in terms of year
     for ($i = 0; $i < $year - $init_engYear; $i++) {
         //total days for month calculation(english)
         if (Utility::isLeapYear($init_engYear + $i) == 1) {
             for ($j = 0; $j < 12; $j++) {
                 $totalDays_eng += $leap_month[$j];
             }
         } else {
             for ($j = 0; $j < 12; $j++) {
                 $totalDays_eng += $general_month[$j];
             }
         }
     }
     //Count total no. of days in-terms of month
     for ($i = 0; $i < $month - 1; $i++) {
         if (Utility::isLeapYear($year) == 1) {
             $totalDays_eng += $leap_month[$i];
         } else {
             $totalDays_eng += $normal_month[$i];
         }
     }
     // count total no. of days in-terms of date
     $totalDays_eng += $day;
     //Initialization of values
     $weekDay = 7 - 1;
     $numDay = 0;
     $a = 0;
     $i = 0;
     $j = $init_nepMonth;
     $y = $init_nepYear;
     $m = $init_nepMonth;
     $totalDays_nep = $init_nepDay;
     //Caluating equivalent nepali date
     while ($totalDays_eng != 0) {
         $a = $bs[$i][$j];
         $totalDays_nep++;
         $weekDay++;
         if ($totalDays_nep > $a) {
             $m++;
             $totalDays_nep = 1;
             $j++;
         }
         if ($weekDay > 7) {
             $weekDay = 1;
         }
         if ($m > 12) {
             $y++;
             $m = 1;
         }
         if ($j > 12) {
             $j = 1;
             $i++;
         }
         $totalDays_eng--;
     }
     $numDay = $weekDay;
     //storing converted value in array
     $newDate = array();
     $newDate["year"] = $y;
     $newDate["num_month"] = sprintf("%02d", $m);
     $newDate["day"] = sprintf("%02d", $totalDays_nep);
     $newDate["alpha_weekDay"] = Day::getWeekDay($weekDay);
     $newDate["alpha_month"] = NepaliFormat::getMonth($m);
     $newDate["num_weekDay"] = $numDay;
     if ($formatOpt == false) {
         return $newDate;
     }
     $newDate['format'] = $this->format;
     $cDate = Utility::formatResult($newDate);
     return $cDate;
 }