This is a migrated thread and some comments may be shown as answers.

(Monday) FirstDayOfWeek

8 Answers 183 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
arjen
Top achievements
Rank 1
arjen asked on 04 Dec 2010, 05:29 PM

I made changes to get CultureInfoCurrentCulture.DateTimeFormat.FirstDayOfWeek the first day of the week (for The Netherlands: Monday):

telerik.common.js:

firstVisibleDay: function (date, value) {
    var firstVisibleDay = new $t.datetime(date.year(), date.month(), 0, date.hours(), date.minutes(), date.seconds(), date.milliseconds());
    while (firstVisibleDay.day() != value) {
        $t.datetime.modify(firstVisibleDay, -1 * $t.datetime.msPerDay)
    }
    return firstVisibleDay;
},

telerik.calendar.js:
firstDay = 1 (Monday), I dont know how to use CultureInfoCurrentCulture.DateTimeFormat.FirstDayOfWeek in javascript
var firstDay = 1;
for (var i = firstDay; i < firstDay + 7; i++) {
    html.cat('<th scope="col" abbr="')
        .cat($t.cultureInfo.abbrDays[i % 7])
        .cat('" title="')
        .cat($t.cultureInfo.days[i % 7])
        .cat('">')
        .cat($t.cultureInfo.days[i % 7].charAt(0))
        .cat('</th>');
}
html.cat('</tr></thead><tbody>');
var currentDayInCalendar = $t.datetime.firstVisibleDay(viewedMonth, firstDay);

Calendar.cs:
BuildWeekHeader:
  
            int firstDay = (int)CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek;
  
            for (int day = firstDay; day < firstDay + 7; day++)
            {
                row.Children.Add(renderer.HeaderCellTag(CultureInfo.CurrentCulture.DateTimeFormat.DayNames[day % 7]));
            }
  
  
BuildMonthView:
            int firstDayOfMonthView = DateTime.DaysInMonth(prevMonth.Year, prevMonth.Month) - ((int)(prevMonth).DayOfWeek) + 
(int)CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek;

8 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 07 Dec 2010, 04:26 PM
Hello arjen,

Unfortunately choosing FirstDayOfWeek is not supported for the time being. Similar request is logged in our PITS, where you can vote for it.

Nevertheless the current votes, our goal is to implement this functionality for the next official release of the Telerik Components for ASP.NET MVC.

Kind regards,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
arjen
Top achievements
Rank 1
answered on 08 Dec 2010, 07:45 AM
Hello Georgi,

Its was not a question but some code donation (changes in Telerik source code) to make the calendar culture compliant.
My apologizes if it is the wrong place or not appreciated to donate some code.

Regards,
Arjen
0
Georgi Krustev
Telerik team
answered on 08 Dec 2010, 08:51 AM
Hello Arjen,

Thank you for the code snippets and sorry for the misunderstanding.

We will further develop given idea in order to cover all possible scenarios. Unfortunately we will not be able to use the given code snippets directly in Calendar UI component.

Regards,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Rafael
Top achievements
Rank 1
answered on 27 Jan 2011, 03:24 PM
in PITS it has status RESOLVED, but I don't see this feature in 2010.3.1318 build.
I am quite uncertain about what was fixed?
For me Monday as a first day is working in calendar, but doesn't work in date picker
Please advise
0
Georgi Krustev
Telerik team
answered on 27 Jan 2011, 03:57 PM
Hello arjen,

Check this online demo, which shows that the FirstDayOfWeek works as expected.

Regards,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Rafael
Top achievements
Rank 1
answered on 27 Jan 2011, 05:15 PM
  It doesn't work still: please see attached image
0
Accepted
Georgi Krustev
Telerik team
answered on 27 Jan 2011, 05:39 PM
Hello Rafael,

FirstDayOfWeek is connected with current culture. In other words if the culture is en-US, then the first day of week will be Sunday. You can observe this behavior in the demo which was linked in my previous message.

If you need to show first day of week to be not related with the current culture, then you will need to set it manually with overriding $.telerik.cultureInfo.firstDayOfWeek:

<% Html.Telerik().ScriptRegistrar()
                .OnDocumentReady(()=>{
                  %>
                         $.telerik.cultureInfo.firstDayOfWeek = 1; // thus the first day of week will be Monday.
                  <%
                })
                .Render();
%>

Best wishes,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Rafael
Top achievements
Rank 1
answered on 27 Jan 2011, 05:51 PM
Guys, thanks so much for your help
Tags
Calendar
Asked by
arjen
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
arjen
Top achievements
Rank 1
Rafael
Top achievements
Rank 1
Share this question
or