|
PowerBASIC Forums
![]() PowerBASIC for Windows
![]() Week of Day ? (Page 1)
|
This topic is 3 pages long: 1 2 3 |
next newest topic | next oldest topic |
| Author | Topic: Week of Day ? |
|
Matthias Kuhn Member |
Hello, how to get the week-number of a given ( actual ) day ??? Thanks and regards. Matthias Kuhn ------------------ IP: Logged |
|
Shawn Anderson Member |
I'm not sure what you mean... Do you want to take a date and figure which week of the year (1-52) that day falls into? ------------------ IP: Logged |
|
Eric Pearson Member |
Matthias -- There are several different methods for determining the week number. Does week 1 start on January 1, or is it the first full week in January, or does it start in December if there are 1-6 days left over from the previous year...? Search these forums and you will find a number of discussions about this topic, and lots of code. -- Eric ------------------ IP: Logged |
|
Ron Dunn Member |
The following query gives HUNDREDS of examples: http://www.google.com.au/search?sourceid=navclient&ie=UTF-8&rls=GGLG,GGLG:2005-51,GGLG:en&q=algorithm+date+to+week+number ------------------ IP: Logged |
|
Egbert Zijlema Member |
Matthias, Windows supports 2 or 3 methods to calculate week numbers. One method is based on a calendar that shows Sundays as the first day of the week (as used in the USA). ------------------ [This message has been edited by Egbert Zijlema (edited January 01, 2006).] IP: Logged |
|
Egbert Zijlema Member |
Matthias, No need to send me an e-mail. I posted the code already, but it was so long ago that I did not remember. ------------------ IP: Logged |
|
Michael Mattias Member |
>Windows supports 2 or 3 methods to calculate week numbers APIs? I can't find any functions in SDK which do anything with 'week numbers.' IP: Logged |
|
Peter Jinks Member |
quote: Perhaps you're not looking hard enough. Try VarFormat, see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/automat/html/2e1b4fd1-a86b-4933-8934-5d725168a2cd.asp Regards, Pete. [This message has been edited by Peter Jinks (edited January 01, 2006).] IP: Logged |
|
Egbert Zijlema Member |
I'm sorry. Of course there is no support in that way. It is a rather long time ago when I was oocupied with this stuff, but I certainly do remember the 3 possibilities:
As a European I stick to the ISO-rules which are mandatory in all the member states of the European Union. ------------------ IP: Logged |
|
Egbert Zijlema Member |
It is, indeed, a long time ago, folks. I once started a project dealing with this issue, but due to several causes I never finished it. And yes, Windows does support week numbers in a way. You should call GetLocaleInfo, passing %LOCALE_IFIRSTWEEKOFYEAR as LCType, to retrieve a value from 0 - 2. This is what those values mean:
The latter is very close to ISO-rule 8601. However, according to ISO a second rule applies: Monday is the first day of the week. Maybe this is always the case by default? I mean: maybe %LOCALE_IFIRSTWEEKOFYEAR returns a value of 2 only when at the same time %LOCALE_IFIRSTDAYOFWEEK returns 0 (= Monday)? I don't know, because I did not find information from Microsoft available. Here's some code. It is rather surprising, because several member states of the European Union do not strictly follow ISO-rules. Although Monday is considered to be the first day of the week, those countries consider the week wherein January 1 falls to be week number 1. Anyhow, this is the case on my box, running XP Home and SP1. I do not know if the programmers from Redmond did a good job here. Can somebody, living in those countries (Spain, France, Belgium) confirm this? Another surprise is that I did not find countries where the first full week is week number 1. Surprise #3: I did not find Tuesday thru Saturday as first day of the week. NOTE: The forthcoming days I will add a working week number routine to my well known Gregorian functions.
------------------ Egbert Zijlema, journalist and programmer (egbert at egbertzijlema dot nl) http://www.egbertzijlema.nl/programming.html *** Opinions expressed here are not necessarily untrue *** [This message has been edited by Egbert Zijlema (edited January 03, 2006).] IP: Logged |
|
Egbert Zijlema Member |
Windows does support week numbers. See: previous message in this thread. ------------------ IP: Logged |
|
Michael Mattias Member |
GetLocaleInfo==> perfect to get week number based on my locale setting. But... is there a way to set that? On control panel, there is no place under 'regional settings' (which is where Windows help sent me) for 'week method' or 'first day of week'. Or is this something supplied with the O/S and you live with it, adjusting that 'week number' if necessary based on the factory-installed options? IP: Logged |
|
Egbert Zijlema Member |
It's in the registry. See: HKEY_CURRENT_USER\Control Panel\International ------------------ [This message has been edited by Egbert Zijlema (edited January 03, 2006).] IP: Logged |
|
Matthias Kuhn Member |
Thanks all for response ! Egbert I´ll take Your old code from the October 20, 2002, because I`think there are a Windows-Solution too - but I´m new with found in CommCrtl.inc %MCS_WEEKNUMBERS = &H0004 Thanks for help an using Your Code. Best Regards Matthias Kuhn ------------------ IP: Logged |
|
Paul Dixon Member |
Mattias, <<I´m new with PB8 Win and it is quicker to use a longer code and spend less time to think of API Commands:>> I think this is a general problem with Windows programming. People spend way too much time trying to find/understand/shoe horn into their application a complicated Windows way of doing things which takes far longer in many cases than just writing the code from scratch. Paul. ------------------ IP: Logged |
This topic is 3 pages long: 1 2 3 All times are EasternTime (US) | next newest topic | next oldest topic |
![]() |
|
Copyright © 1999-2007 PowerBASIC, Inc. All Rights Reserved.