public void testFormattedNepaliDateInMDYFormat() { nepaliDate.setFormattedDate(2074, 01, 25, DateFormats.mDy); Assert.AreEqual("01-25-2074", nepaliDate.getFormattedDate()); }
public NepaliDate ToBS(DateTime gDate, NepaliDate.DateFormats date_format = NepaliDate.DateFormats.yMd) { gDate = gDate.Date; //Breaking given english date int yy = 0; int mm = 0; int dd = 0; yy = gDate.Year; mm = gDate.Month; dd = gDate.Day; //English month data int[] month = new int[] { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; int[] lmonth = new int[] { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; int def_eyy = 0; int def_nyy = 0; int def_nmm = 0; int def_ndd = 0; int total_eDays = 0; int total_nDays = 0; int a = 0; int m = 0; int y = 0; int i = 0; int j = 0; //Initialize english date Tuple <int[], int[], int> initializationDates = conversionStartDateData.getClosestEnglishDateAndNepaliDate(gDate); int[] english_init_date = initializationDates.Item1; int[] nepali_init_date = initializationDates.Item2; // def_eyy = 1944; def_eyy = english_init_date[0]; //Equivalent nepali date def_nyy = nepali_init_date[0]; def_nmm = nepali_init_date[1]; def_ndd = nepali_init_date[2]; //Initializations total_eDays = 0; total_nDays = 0; a = 0; m = 0; i = 0; j = 0; //count total number of english days using standard date functions total_eDays = Convert.ToInt32((gDate - new DateTime(def_eyy, 01, 01)).TotalDays) + 1; //below i is the starting nepali year, used in looping to loop through years above the specified year i = def_nyy; j = def_nmm; total_nDays = def_ndd; m = def_nmm; y = def_nyy; //Count nepali date from array while ((!(total_eDays == 0))) { a = nepaliDateData.getLastDayOfMonthNep(i, j); total_nDays += 1; if ((total_nDays > a)) { m += 1; total_nDays = 1; j += 1; } if ((m > 12)) { y += 1; m = 1; } if ((j > 12)) { j = 1; i += 1; } total_eDays -= 1; } NepaliDate nep_date = new NepaliDate(); nep_date.npDay = total_nDays; nep_date.npDaysInMonth = a; nep_date.npMonth = m; nep_date.npYear = y; //1 is added since we are using Sunday as 1 although it is 0 nep_date.dayNumber = (int)gDate.DayOfWeek + 1; nep_date.dayName = gDate.DayOfWeek.ToString(); nep_date.setFormattedDate(y, m, total_nDays, date_format); return(nep_date); }