B
bojan.pikl
Hi, I am making a calendar. It is costum made and I would like to have
the ability to choose the first day (Monday or Sunday). I know for the
firstDayOfWeek, but I can't change it. What should I do?
I tried this but it does not work (it is always Sunday):
using System.Globalization;
....
CultureInfo culture = (CultureInfo)CultureInfo.CurrentCulture.Clone();
CultureInfo uiculture =
(CultureInfo)CultureInfo.CurrentUICulture.Clone();
if (day == "Monday")
{
culture.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Monday;
uiculture.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Monday;
}
else
{
culture.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Sunday;
uiculture.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Sunday;
}
System.Threading.Thread.CurrentThread.CurrentCulture = culture;
System.Threading.Thread.CurrentThread.CurrentUICulture = uiculture;
The code works fine but it's always Sunday the first day of week. I
would like to change this.
And here is my code:
int DayIndex;
DateTime objDate=new DateTime(Year,Month,Day);
//First day of week.
int StartDayIndex=(int)objDate.DayOfWeek;
//Empty array days.
for(int i=0; i<37; i++)
days=0;
for(int i=0; i<31; i++)
{
DayIndex=(StartDayIndex+i);
if(i < DateTime.DaysInMonth(Year,Month))
{
days[DayIndex]=(i+1);
}
else
{
days[DayIndex]=0;
}
}
the ability to choose the first day (Monday or Sunday). I know for the
firstDayOfWeek, but I can't change it. What should I do?
I tried this but it does not work (it is always Sunday):
using System.Globalization;
....
CultureInfo culture = (CultureInfo)CultureInfo.CurrentCulture.Clone();
CultureInfo uiculture =
(CultureInfo)CultureInfo.CurrentUICulture.Clone();
if (day == "Monday")
{
culture.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Monday;
uiculture.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Monday;
}
else
{
culture.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Sunday;
uiculture.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Sunday;
}
System.Threading.Thread.CurrentThread.CurrentCulture = culture;
System.Threading.Thread.CurrentThread.CurrentUICulture = uiculture;
The code works fine but it's always Sunday the first day of week. I
would like to change this.
And here is my code:
int DayIndex;
DateTime objDate=new DateTime(Year,Month,Day);
//First day of week.
int StartDayIndex=(int)objDate.DayOfWeek;
//Empty array days.
for(int i=0; i<37; i++)
days=0;
for(int i=0; i<31; i++)
{
DayIndex=(StartDayIndex+i);
if(i < DateTime.DaysInMonth(Year,Month))
{
days[DayIndex]=(i+1);
}
else
{
days[DayIndex]=0;
}
}