AutoHotkey Community

It is currently May 27th, 2012, 5:29 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: February 27th, 2010, 12:52 am 
Offline

Joined: January 15th, 2008, 1:46 pm
Posts: 28
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.

Quote:
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.


Code:
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):
Image

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 27th, 2010, 7:12 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
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!).

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Last edited by PhiLho on February 28th, 2010, 2:07 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 28th, 2010, 7:21 am 
Offline

Joined: August 24th, 2005, 5:29 pm
Posts: 549
Location: Berlin / Germany
The help for FormatTime wrote:
WDay: Day of the week (1 – 7). Sunday is 1.

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

_________________
nick :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2010, 3:16 pm 
Offline

Joined: January 15th, 2008, 1:46 pm
Posts: 28
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.

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.

Quote:
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.

Quote:
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:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2010, 9:07 pm 
Offline

Joined: January 15th, 2008, 1:46 pm
Posts: 28
FWIW... I found a solution for Win7 in this old thread: http://www.autohotkey.com/forum/topic991.html


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.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group