Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Monthcal - Week numbers wrong


  • Please log in to reply
4 replies to this topic
TedStriker
  • Members
  • 30 posts
  • Last active: Jul 31 2013 09:33 PM
  • Joined: 15 Jan 2008
I need a little calendar with week display sometimes. I used "BetaClock" for this, but it stopped working under Win7. The next best thing I found was "Amp Calendar" but it calculated the weeks wrong for 2010 . So finally I thought I should just use AHK (1.0.48.05). But what do you know, AHK also calculates the weeks wrong. At least the help file says it should calculate the weeks correctly, so I report it as bug.

4: Specify the number 4 in Options to display week numbers (1-52) to the left of each row of days. Week 1 is defined as the first week that contains at least four days.


Gui +AlwaysOnTop +Owner
Gui, Add, MonthCal, 4 x2 y0 w190 h160,
Gui, Show, x276 y398 h166 w197, Calendar
Return

GuiClose:
ExitApp

And here's what it looks like (Win7 64bit):
Posted Image

Week 1 should start, just as the help files says (and some ISO definition on Wikipedia) with fourth of January.

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
I am suspecting both AMP Calendar and AutoHotkey to rely on Windows' API to get the date information, not calculating manually.
For the record, I found an interesting article: Calculating the ISO week number which defines "week 1 of a given year is the one that includes the first Thursday of that year. (or, equivalently, week 1 is the week that includes 4 January.)", so, indeed, according to this rule, this year's first week starts on January 4.

I was wondering about your post because I have AMP Calendar (a good, lightweight application) and I ran your script.
Both correctly report first week starting on January 4...

Then I had a suspicion... I went to the computer of my wife, running Windows 7. Lo! The calendar utility shown week 1 on first day of January...
I don't know which system they use (apparently there are several...) but it is.. disconcerting! It won't ease communication between one person on Windows XP (like me) and Windows 7! ("the deadline is set on week 11")...

Well, the conclusion is that this is not a bug in AHK...

[EDIT] For the record, it seems to be an old problem with MS products...
See Week numbers in Outlook Calendar are not consistent with Europe and Outlook 2002 shows wrong week numbers (last message, particularly: looks like we can change that in Outlook).
Apparently, Windows 7 beta has No week numbers in calendar, but they fixed that later, but incorrectly as it seems... Or inconsistently. Note that XP doesn't show week numbers either. I also notice: we have a calc, but no cal out of the box (beside these dialogs to change date/time)?
See also CalendarWeekRule Enumeration (found that by looking at the Determining the week number of 31/12/2008, because .NET is wrong thread where I found three links to various bug reports at Microsoft's site, with confusing answers from Microsoft...).
Apparently, the rules are culture dependent (as I guessed) and thus depend on the chosen parameter.
I still think it is strange to have differences between Windows XP and 7 (for the same locale, French in my case!).
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

nick
  • Members
  • 549 posts
  • Last active: Jul 03 2010 09:31 PM
  • Joined: 24 Aug 2005

WDay: Day of the week (1 – 7). Sunday is 1.

So isn't it somewhat consistent (for MS at least)?
nick :wink:

TedStriker
  • Members
  • 30 posts
  • Last active: Jul 31 2013 09:33 PM
  • Joined: 15 Jan 2008
Thanks for your post, PhiLho.

This is interesting. I tried the same script at my workplace (Windows XP, same region setting (German), Monday = first day of week) and it displays the correct week.

Posted Image

Ha! Now I understand why the author of AMP Calendar never bothered to reply my e-mail. He must have thought I'm crazy. :lol:

So, there, another one of the "worked flawlessly under Windows XP, but somehow not under Windows 7" bugs I encountered (like Desktop stops auto-refresh, audio crackles under CPU load, energy settings won't remember power-button setting). There's nothing I can do, but hope the first service pack will fix such tiny bugs.

Well, the conclusion is that this is not a bug in AHK...


The help file let me hope AHK would have own routines to calculate the work week and not rely on Windows. Perhaps this will be changed, seeing Microsoft has some problems with it.

old problem with MS products...


I know MS Access has problems with it, since ages (Access 2000). That's why I use a script-function which transforms a date to (correct) week number and do not use Access internal function. :idea:

TedStriker
  • Members
  • 30 posts
  • Last active: Jul 31 2013 09:33 PM
  • Joined: 15 Jan 2008
FWIW... I found a solution for Win7 in this old thread: <!-- m -->http://www.autohotke...m/topic991.html<!-- m -->


HKEY_CURRENT_USER\Control Panel\International\iFirstWeekOfYear

Set it to 1 and voila... Correct ISO 8601 week display in MonthCal (or AMP calendar).


The variable A_YWeek is not affected by this registry setting. It always calculates the ISO 8601 week. So I still wish MonthCal would use A_YWeek and not rely on Windows.