Hi
I need to work with Nepali dates.................Does anyone has any algorithm or idea on converting Eng to Nepali or Nepali to Eng Dates?
CooSHal Gautam
Kushal i am glad that you are also working as a rpogrammer.
Some previous programmers have already created a class for conversion of that type. I have also tried but not succed in this case.
If you have link with other programmer then contact them.
I am now working for it but not have yet that class. If i wil get hat class then i will send you that class.
Good luck man.
Ohh!! really?? But I've been trying to find those classes or codes since 2/3 years. Well, m working with an idea. Let's see if I succeed, then will definitely post it over here....
Thanks.....
If you are really going to design that class then i heard that the coder used to list out all the lenths of months first in an array and first date conversion is known for them then they used to calculate by populating each day of eack month by which they get info about the napali date.
This information may help you.
Best of luck yar.
yeah indeed..........
I have listed all the length of months and then their respective Eng Month and then calculated the Nepali Dates accordingly... I am taking help from a database programmer. He's guiding me through MS-SQL for this purpose.
And yeah, thanks for your information. It was informative...
Hi Kushal!
Strange, I could not find API/dll that converts Nepali date, If possible, you could create it as a dll and put for public, I am also thinking to write it but xml based, but I am afraid of time it takes to fill in the dates, I could allow user to fill themselves but would be nice to have some years data there. I will let you know If I go that way.
Have a good day!
Arjun PaudelMicrosoft MVP
http://www.mydotnetblog.org
Hi Guys,
you follow this technique.
1. Create the database table of calendar like this..
2. use following code..u know .net C#
public class CalendarConverterBL { public string ConvertEnglishToNepali(string date) { try { DateTime englishDate = Convert.ToDateTime(date); tbl_Lu_CalendarTableAdapter da = new tbl_Lu_CalendarTableAdapter(); CalendarDataset.tbl_Lu_CalendarDataTable dt = da.GetCalendarInformationByStartAndEndDate(englishDate.ToShortDateString()); if (dt.Count <= 0) { throw new ApplicationException("Date you have selected is not in the Calendar table."); } CalendarDataset.tbl_Lu_CalendarRow dr = dt.FindBynYear(Convert.ToInt32(dt.Rows[0][0])); TimeSpan timediff = englishDate.Subtract(dr.StDate); int totaldays = timediff.Days; int remainingDays = totaldays; int i = 1; if (dr.Baishakh < totaldays) { remainingDays = totaldays - dr.Baishakh; i++; if (dr.Jesth < remainingDays) { remainingDays = remainingDays - dr.Jesth; i++; if (dr.Ashadh < remainingDays) { remainingDays = remainingDays - dr.Ashadh; i++; if (dr.Shrawan < remainingDays) { remainingDays = remainingDays - dr.Shrawan; i++; if (dr.Bhadra < remainingDays) { remainingDays = remainingDays - dr.Bhadra; i++; if (dr.Ashwin < remainingDays) { remainingDays = remainingDays - dr.Ashwin; i++; if (dr.Kartik < remainingDays) { remainingDays = remainingDays - dr.Kartik; i++; if (dr.Mansir < remainingDays) { remainingDays = remainingDays - dr.Mansir; i++; if (dr.Paush < remainingDays) { remainingDays = remainingDays - dr.Paush; i++; if (dr.Magh < remainingDays) { remainingDays = remainingDays - dr.Magh; i++; if (dr.Falgun < remainingDays) { remainingDays = remainingDays - dr.Falgun; i++; if (dr.Chaitra < remainingDays) { remainingDays = remainingDays - dr.Chaitra; i++; } } } } } } } } } } } } remainingDays++; string nepaliDate = dr.nYear.ToString() + "/" + i.ToString() + "/" + remainingDays.ToString(); return nepaliDate; } catch { return "-1"; } } public DateTime ConvertNepaliToEnglish(string nepalidate) { try { string[] tempNepaliDate = nepalidate.Split('/'); int year = Convert.ToInt32(tempNepaliDate[0]); int month = Convert.ToInt32(tempNepaliDate[1]); if (month > 12) return new DateTime(1900, 1, 1); int day = Convert.ToInt32(tempNepaliDate[2]); if (day > 32) return new DateTime(1900, 1, 1); tbl_Lu_CalendarTableAdapter da = new tbl_Lu_CalendarTableAdapter(); CalendarDataset.tbl_Lu_CalendarDataTable dt = da.GetAllCalendar(); CalendarDataset.tbl_Lu_CalendarRow dr = dt.FindBynYear(year); if (dr==null) { return new DateTime(1900, 1, 1); } int days = 0; for (int i = 1; i < month; i++) { days += MapMonthWithDay(i, dr); } days += day; days--; DateTime startenglishdate = dr.StDate; DateTime currentenglishdate = startenglishdate.AddDays(days); return currentenglishdate; } catch { return new DateTime(1900, 1, 1); } } public int MapMonthWithDay(int month, CalendarDataset.tbl_Lu_CalendarRow dr) { int days = 0; switch (month) { case 1: days = dr.Baishakh; break; case 2: days = dr.Jesth; break; case 3: days = dr.Ashadh; break; case 4: days = dr.Shrawan; break; case 5: days = dr.Bhadra; break; case 6: days = dr.Ashwin; break; case 7: days = dr.Kartik; break; case 8: days = dr.Mansir; break; case 9: days = dr.Paush; break; case 10: days = dr.Magh; break; case 11: days = dr.Falgun; break; case 12: days = dr.Chaitra; break; default: break; } return days; } }
Ok, here is my xml version, just few hours work, I will improve with time
http://www.mydotnetblog.org/My%20Blog/blog/default.aspx?id=20&t=Convert-English-DateAD-to-Nepali-Date
Hey you guys do best job yar
It is much useful to all nepali programmers
Ahh!!
Actually I missed out to acknowledge on this occassion.
Thank You guys.....thanks for your innovative response......This's gonna help every nepali programmer...
If possible I'll show u the databse version too...