Jump to content


Photo

NxMonthCalendar shows the wrong day of the week name on calendar.


  • Please log in to reply
3 replies to this topic

#1 FourWhey

FourWhey
  • Members
  • 165 posts

Posted 27 October 2016 - 06:15 PM

I forgot I switched to the new control. The control is actually NxDatePicker6 and this is in the wrong forum.

 

Today is Thursday Oct. 27, 2016 and the control is showing that it's Friday Oct. 27, 2016.

 

http://i.imgur.com/udGeeeX.png

 

My system settings have First day of week set to Sunday. When I inspect the value at runtime, StartDayOfWeek is always dwMonday, even though I've overridden the value to dwSunday in the control properties, and dwSystem returns Sunday from the locale.

 

Edit: I changed FView.StartDay to

FView.StartDay := dwSystem;  // dwMonday

The design time value set for StartDayOfWeek is ignored.  I tried changing FView.StartDay := StartDayOfWeek and found that the value set at design time still didn't work and when destroying FView it threw an invalid pointer exception so I changed it back to dwSystem. This fixes one problem - sort of - but the dates and days of the week still don't line up with the correct column.

 

Edit2: I changed TNxDatePickerView.PaintDays(1767) to the following and it fixes the dates not lining up with the day of the week. I see that a similar method is used elsewhere (GetDayRect, IsShown) but didn't test if those needed alteration.

Day := IncDay(Day, -GetDayOfWeek(StartOfAMonth(Year, Month)) +1);

Edit3: Since SetHover calls RefreshDay and that calls IsShown and GetDayRect the OnHover rectangle isn't working right. I changed the Day assignment to what I used in PaintDays but it's one day behind. I'll keep messing with it, but this thing has some problems.

 

Edit4: I found the problem. I reverted everything I did, and started looking at other things because it seemed like something was off by a day. I then looked at what GetDayOfWeek returns and noticed that the values here needed to be swapped. Here's what I changed it to and it works correctly now. 

 

So to recap, change FView.StartDay to default to dwSystem and fix it so the design time value set for StartDayOfWeek can override the default and alter GetDayOfWeek as seen below.

function TNxDatePickerView.GetDayOfWeek(Day: TDateTime): Integer;
begin
  Result := 0;

  case GetActualStartDay of
    dwSunday: Result := DayOfTheWeek(Day);
    dwMonday: Result := DayOfWeek(Day);
  end;
end;


#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 30 October 2016 - 04:35 PM

Hi,

 

I changed it (and changed some more code). Please check if all is well in next update.


boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 FourWhey

FourWhey
  • Members
  • 165 posts

Posted 31 October 2016 - 03:30 PM

Thank you. I'll check it out, when it's uploaded.

 

zip.png nextsuite6_10-16.zip

  7,333 KB

  Oct 02, 2016



#4 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 31 October 2016 - 08:51 PM

Hi,

 

Will be in a couple of days, need to alter some more other code too.


boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users