views:

89

answers:

2

I am in Ethiopia and we have 13 months. 12 of them with 30 days each and 13th month with 5 or 6 days. I want to sort my data by date using the BindingSource sort method. But to do that, I need to set my date field a date data type. When I set the DataType to date, I can't enter some values like 13 for the month value and 30 for day value of 2nd month.

What I want is just to make my application accept 13 as a month and 30 as a day for all months, so that I can sort my data by date. Is it possible to do so by setting culture for my application or by some other means?

+3  A: 

In theory, you could load up the CultureInfo corresponding to language/country for Ethiopia. It appears that the native language in Ethiopia is Amharic which has ISO 639 short code of "am" and the ISO 3166 country code for Ethiopia is "ET". Thus, it appears that the correct culture code for Ethiopia is "am-ET". Thus, try the following.

CultureInfo ethiopia = new CultureInfo("am-ET");
int year = 2002; // it is currently 2002 in Ethiopia
int months = ethiopia.Calendar.GetMonthsInYear(year);
for (int i = 1; i <= months; i++) {
    Console.WriteLine(ethiopia.Calendar.GetDaysInMonth(year, i));
}

And then, as it is the 13th month that has five or days

DateTime time = new DateTime(2002, 13, 5, ethiopia.Calendar);

would be legal.

If for some reason that doesn't work, you could also look at how to create a custom calendar using this CodeProject on the Vietnamese Lunar Calendar as an example.

Jason
The Ethiopic numbering system is fascinating as it does not have a zero: http://blogs.msdn.com/michkap/archive/2005/02/01/364376.aspx
Jason
How can I do this to change the datatable? I mean it is the datatable that's not accepting the data coming from the database.
Try setting the `DataTable.Locale` property to an instance of `CultureInfo` that represents the "am-ET" culture. I don't know that will work, but it's the first thing to try. The problem is that the `DataTable` will still use the `InvariantCulture` for a vast majority of its functionality.
Jason
setting the locale of the datatable changes nothing. also "am-ET" is not a valid culture name. it seems that ethiopia is not in the caltureinfo culture list. can you show me how to create a custom calendar, the link you gave me is not clear.
A: 

I used this as a solution.

you could add a separate column in your datatable to account for the extra epagomenal days... then sort your data by both columns. for instance: here would be a sample table sorted descending first by Column1 then by Column2:

RegDate----------------EpaDate

12/30/09--------------- 1/5/2010 12/30/09----------------1/4/2010 12/30/09----------------1/3/2010 12/30/09----------------1/2/2010 12/30/09----------------1/1/2010 12/30/09------------------NULL 12/29/09------------------NULL 12/28/09------------------NULL