[SOLVED]TCalendar : False number of the week with windows lazarus / 31-LCL ---------------------------------------------------------------------- gjpneac · 2012-07-17 15:14 Hello, Today's date is Tuesday, July 17, 2012... and Today's Week number is 29... and my TCalendar indicates 30. Look at the attachment please. Regards. ---------------------------------------------------------------------- BigChimp · 2012-07-17 15:19 Depends on your definition of week number. There are multiple definitions across the world. Perhaps you can influence the calculated number with an additional parameter or setting some property. ---------------------------------------------------------------------- gjpneac · 2012-07-17 15:35 Ah... on lazarus planet perhaps... but usually, please, look at http://www.calendardate.com/todays.htm, http://www.epochconverter.com/epoch/weeknumbers.php, http://whatweekisit.com/... Regards. ---------------------------------------------------------------------- KpjComp · 2012-07-17 15:47 Yes, I would have expected Lazarus to be using  ISO-8601, but it appears not. Ironically WeekOf returns the correct ISO-8601 week number. ---------------------------------------------------------------------- gjpneac · 2012-07-17 15:52 Yes, I don't understand : WeekOfTheYear(aCalendar.DateTime) returns 29 on the TCalendar indicates 30;    So  I have a problem of coherence.  . You see ? In Win32WSCalendar :    MCHT_CALENDARWEEKNUM : Result := cpWeekNumber; With Linux (Ubuntu), the number of the week is correct. But the display is bad (look at attachment). Regards. ---------------------------------------------------------------------- KpjComp · 2012-07-17 16:38 Bit of digging, it's actually a windows thing. Try changing this registry value to 2.. HKEY_CURRENT_USER\Control Panel\International\iFirstWeekOfYear ---------------------------------------------------------------------- gjpneac · 2012-07-17 17:00 Yes. It works : I have changed this registry value to 1. By default, it's 0. (Windows 7 Edition Intégrale - Service pack 1 - 32 bits) It is the same value on my other computers with 7 or XP. The iFirstday of the registry is also 0 and the display of the Tcalendar's days are correct. It is thus a very temporary solution. I suppose that it is necessary to indicate the problem on the bug tracker ? Thanks. Regards. ---------------------------------------------------------------------- KpjComp · 2012-07-17 18:06 QuoteI suppose that it is necessary to indicate the problem on the bug tracker ? Well, not in the Lazarus bug tracker, as it's not a Lazarus bug. The Calendar component is just a wrapper for the common controls Calendar component that Microsoft made.  And basically Microsoft gets these settings from it's locale, that was basically the registry entry I showed. Ideally the inconsistency is not ideal, from what I can tell Microsoft gives no option for changing this from the component level, only the registry.  To be consistent Lazarus would need to examine this registry too, and WeekOf/WeekOfTheYear would need modifying too.  Not sure what the Dev's would make of this though. ---------------------------------------------------------------------- KpjComp · 2012-07-17 18:12 Also any reason you set to 1, instead of 2 like I mentioned?. These are the values for iFirstWeekOfYear - 0 Week containing 1/1 is the first week of that year. - 1 First full week following 1/1 is the first week of that year. - 2 First week containing at least four days is the first week of that year. From what I can gather option 2 is the ISO-8601 variant. ---------------------------------------------------------------------- ludob · 2012-07-17 18:50 Quotefrom what I can tell Microsoft gives no option for changing this from the component level, only the registryCode: [Select]uses ...,windows; SetLocaleInfo(LOCALE_SYSTEM_DEFAULT,LOCALE_IFIRSTWEEKOFYEAR, '2');  Note that the 3rd parameter is a string, just as the registry value. ---------------------------------------------------------------------- gjpneac · 2012-07-17 19:23 @Ludob : Perfect. Thank you very much to all of you. Regards. ---------------------------------------------------------------------- KpjComp · 2012-07-17 20:01 Please note this is basically doing the same as modifying the registry. http://msdn.microsoft.com/en- us/library/windows/desktop/dd374049(v=vs.85).aspx QuoteCaution  Because this function modifies values for all application Remarks This function writes to the registry, where it sets values that are associated with a particular user instead of a particular application. So like I said, from what I can gather there is no option to modify at the component level.   A warning for users of your application might be an idea, for a system change like this.  eg. "Please note your locale for Week Number  is not set to ISO-8601, would you like it changing to ISO-8601", or something like that. QuoteLOCALE_SYSTEM_DEFAULT Would this also be better as LOCALE_USER_DEFAULT? What would have been nice is LOCALE_PROCESS_DEFAULT ---------------------------------------------------------------------- BigChimp · 2012-07-17 21:10 Quote from: gjpneac on July 17, 2012, 05:35:14 pmAh... on lazarus planet perhaps... Quote from: gjpneac link=topic=17573@Ludob : Perfect. Thank you very much to all of you. Regards. ---------------------------------------------------------------------- JD · 2012-07-17 21:44 Quote from: ludob on July 17, 2012, 08:50:18 pmQuotefrom what I can tell Microsoft gives no option for changing this from the component level, only the registryCode: [Select]uses ...,windows; SetLocaleInfo(LOCALE_SYSTEM_DEFAULT,LOCALE_IFIRSTWEEKOFYEAR, '2');  Note that the 3rd parameter is a string, just as the registry value. Thanks a lot for the tip. I confirm that it works.