Recent

Author Topic: TCalenderDialog only starts on Monday  (Read 531 times)

Badger

  • Jr. Member
  • **
  • Posts: 70
TCalenderDialog only starts on Monday
« on: May 22, 2020, 12:19:14 pm »
Is there a bug in the TCalenderDialog?  I tried setting the Properties>Display Settings>dsStartMonday to False but it continues to start the week on Mondays
Badger

If at first you don't succeed - you're running about average!

I'm using Windows 10 Lazarus v1.8.4

wp

  • Hero Member
  • *****
  • Posts: 7076
Re: TCalenderDialog only starts on Monday
« Reply #1 on: May 22, 2020, 03:54:47 pm »
Yes, seems to be a bug since the code goes into the widgetset and I do not find any reference to dsStartMonday in Win32WSCalendar.pp.

I have a fix, but before committing it I would like you to test it:
  • Open file "win32wscalendar.pp" from folder lcl\interfaces\win32 of your Lazarus installation.
  • Go to the implementation of TWin32WSCustomCalendar.SetDisplaySettings and add the following code before the "end;":]/li]
Code: Pascal  [Select][+][-]
  1.   if dsStartMonday in ASettings then
  2.     MonthCal_SetFirstDayOfWeek(ACalendar.Handle, 0)
  3.   else
  4.     MonthCal_SetFirstDayOfWeek(ACalendar.Handle, 6);
  • Rebuild the IDE ("Tools" > "Build Lazarus with Profile...", confirm "Do you want to rebuild Lazarus...?"). When the IDE restarts after some time, you can test.
  • Report the results here.
I hope your signature is correct and you really are on Windows. Otherwise ignore my post.

I am a bit hesitant to commit this code because it breaks the lfm file in all countries where the week begins on Monday and the default of the component has dsStartMonday turned off.

Another problem with this fix is that is blindly assumes that the alternative to StartMonday is something like "StartSunday", ie. weeks are allowed to begin either with Monday or Sunday. Is this true on all places of the earth?

Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

winni

  • Hero Member
  • *****
  • Posts: 1353
Re: TCalenderDialog only starts on Monday
« Reply #2 on: May 22, 2020, 04:10:13 pm »
Hi!

DayOfWeek:  Start on Sunday = USA
DayOfTheWeek:  Start on Monday = Rest of the world

Winni

wp

  • Hero Member
  • *****
  • Posts: 7076
Re: TCalenderDialog only starts on Monday
« Reply #3 on: May 22, 2020, 06:51:51 pm »
So why do you think Microsoft would waste man power for setting up a dialog in which every weekday can be selected for week start?

Now I found this: http://chartsbin.com/view/41671
roughly:
- Sunday: North and most of South America, East Asia, South Africa and neighbors
- Monday: Europe, Oceania, most of rest of Asia and South America
- Saturday: Arabian world
- most of Africa not shown.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

eljo

  • Sr. Member
  • ****
  • Posts: 358
Re: TCalenderDialog only starts on Monday
« Reply #4 on: May 22, 2020, 07:14:08 pm »
So why do you think Microsoft would waste man power for setting up a dialog in which every weekday can be selected for week start?
Because it requires the exact same effort with a dialog that can select two?
Now I found this: http://chartsbin.com/view/41671
roughly:
- Sunday: North and most of South America, East Asia, South Africa and neighbors
- Monday: Europe, Oceania, most of rest of Asia and South America
- Saturday: Arabian world
- most of Africa not shown.
The split is religion based. Countries that follow Christianity have Monday as the first day, Judaism based have Sunday as the first day of the week and the rest Muslims or something along those lines I do not remember the details sorry.


Zoran

  • Hero Member
  • *****
  • Posts: 1559
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: TCalenderDialog only starts on Monday
« Reply #5 on: May 22, 2020, 07:32:29 pm »
This DisplaySettings property doesn't seem to exist in Delphi.

Instead, VCL's control actually has FirstDayOfWeek property.

The default should be to get this from OS environment (Regional options in Windows).

This linked page also says:
Quote
To make the left-most day adjust for the locale, set FirstDayOfWeek to dowLocaleDefault.

But I cannot find in docs how this dowLocaleDefault constant is defined.

wp

  • Hero Member
  • *****
  • Posts: 7076
Re: TCalenderDialog only starts on Monday
« Reply #6 on: May 22, 2020, 08:00:57 pm »
So you'd vote for giving up the option dsStartMonday in favor of a new property FirstDayOfWeek? That's a good idea: if existing code must be broken it is better to do it in a way that leads to better code. And the declaration of TCalDayOfWeek (the type of this property) in Delphi has the element dowLocaleDefault at the end which allows to address this later because i expect difficulties in implementing this for all widgesets correctly.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

trev

  • Hero Member
  • *****
  • Posts: 668
  • Former Delphi 1-7 and 10.2 User
Re: TCalenderDialog only starts on Monday
« Reply #7 on: May 23, 2020, 03:43:14 am »
Monday is the first day of the week according to the international standard ISO 8601.
« Last Edit: May 23, 2020, 03:47:06 am by trev »
o Lazarus v2.1.0 r63233, FPC v3.3.1 r45525, macOS 10.14.6 (with sup update), Xcode 11.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 (Parallels VM)
o FPC 3.0.4, FreeBSD 12-STABLE r358002
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

winni

  • Hero Member
  • *****
  • Posts: 1353
Re: TCalenderDialog only starts on Monday
« Reply #8 on: May 23, 2020, 03:43:24 am »
So why do you think Microsoft would waste man power for setting up a dialog in which every weekday can be selected for week start?

Now I found this: http://chartsbin.com/view/41671
roughly:
- Sunday: North and most of South America, East Asia, South Africa and neighbors
- Monday: Europe, Oceania, most of rest of Asia and South America
- Saturday: Arabian world
- most of Africa not shown.


Monday is the first day of the week according to the international standard ISO 8601


Winni

PS.: 10 seconds to late

Badger

  • Jr. Member
  • **
  • Posts: 70
Re: TCalenderDialog only starts on Monday
« Reply #9 on: May 24, 2020, 12:39:12 am »
I always knew we Aussies were a perverse mob.  Our calendars start on Sunday so we don't fit any of the arguments for start day above.  :)

I don't want to make the calendar specific to Windows so I will leave it for now - linking it to the local settings would seem a good idea in the future.

Thanks for all the work everyone has done on Lazarus - it really is a great Project!
Badger

If at first you don't succeed - you're running about average!

I'm using Windows 10 Lazarus v1.8.4

wp

  • Hero Member
  • *****
  • Posts: 7076
Re: TCalenderDialog only starts on Monday
« Reply #10 on: May 25, 2020, 04:50:02 pm »
I committed a new version of TCalendar to Laz-trunk (r63220) in which the option dsStartMonday has been removed and replaced by a new Delphi-compatible(*) property FirstDayOfWeek which can be set to any weekday. The default value, dowDefault, is the default provided by the widgetset. Note that still only the win32, qt and qt5 widgetsets provide an interface to change the first day of the week, in the other cases the property is without effect leaving the widgetset default unchanged.

See also: https://wiki.freepascal.org/Lazarus_2.2.0_release_notes#TCalendar:_option_dsStartMonday_of_DisplaySettings_replaced_by_Delphi-compatible_FirstDayOfWeek_property

-----------
(*) Not 100% delphi-compatible because I named the default option dowDefault in contrast to dowLocaleDefault of Delphi. I did this because it is the default defined by the widgetset, not by the "Locale" (with gtk2, for example, the week begins by default on Sunday, while it begins on Moday with qt(5) on the same system).
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

 

TinyPortal © 2005-2018