![]() |
|
#1
|
|||
|
|||
Return month by providing work weekIs there any function by providing work week to return the month in Visual C++?
example: work week 07 fall in february work week 09 fall in march |
|
#2
|
||||
|
||||
|
i don't think there is such function in VC++, but you can always write your own function...
Week 9 = 9 * 7 = 63 so you just have to keep adding number of days in each month and find where week 9 falls into... i think its that simple, thre was once a thread to count something like this... let me search first..hmmmm ahhhaaaa here: a program by dilmv, http://www.gidforums.com/t-4037.html CPP / C++ / C Code:
__________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds |
|
#3
|
|||
|
|||
|
Quote:
at first i also do as what u do but somebody tell me that there got a function returning month by providing work week.. so i try to search on it.. |
|
#4
|
||||
|
||||
|
well, i never heard of a function like that.. hmm hav you tried google or MSDN, if you still can't find better go to that person and ask him where did he find that function,
if its me, i won't waste time searching for it, when i can also do the same thing, just use this one untill maybe one day i find that function... __________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds |
|
#5
|
|||
|
|||
|
Quote:
i think so... thanks!! |
|
#6
|
|||
|
|||
|
Quote:
There are four methods of numbering work weeks that I have seen over the years (different companies, different continents): 1. The week containing Jan 1 is Week #1. The next Sunday is the beginning of Week #2. 2. The week containing the first Sunday of the year is Week #1. The next Sunday is the beginning of Week #2. 3. The week containing Jan 1 is Week #1. The next Monday is the beginning of Week #2. 4. The week containing the first Monday of the year is Week #1. The next Monday is the beginning of Week #2. Some weeks could be in one month or another, depending not only on the calendar year, but also on the scheme used. Is Week 5 in January or February? Is Week 23 in May or June. It depends. I will describe the inverse of your problem. Given a calendar year, how do we calculate the work week number for a given day. Now, given one of the above options, and given the day of the week of Jan 1, we can step through the calendar week-by-week to assign numbers to successive weeks. Note that there are still a few decisions to make. Consider this year (Jan 1 is Saturday). Suppose we are using scheme #1 above. Then the week beginning with Sunday, Jan 2, is Week #2, and the week beginning on Sunday, Dec 27, 2004, would be Week #1 of 2005. (But it could have been Week #53 of 2004.) Suppose we are using scheme #2 above. Then the week beginning with Sunday, Jan 2, is Week #1, and the week beginning with Sunday, Dec 25, is Week #52. That seems OK. But what is the week that contains Jan 1, 2005? Is it week #0 of 2005? Is it week #52 of 2004? What number do we print on the 2005 calendar? Note also that if we had Jan 1 on Saturday and it was a leap year, then Sunday, December 31, would be the beginning of Week 53 of that year. So that year could have weeks numbered from 0 to 53. Fun, huh? If you find some calendar program on the web, be sure to test all possibilities (most amateurish efforts that I have seen don't take everything into account). When writing the program be sure to state your assumptions (scheme #1, #2, #3, #4, above, or whatever other way you want to do it). Test with all possible calendars (There are only 14 possible calendars, you know, so it's not very burdonsome to test every possible input.) Regards, Dave Last edited by davekw7x : 21-Feb-2005 at 09:42.
|
|
#7
|
|||
|
|||
|
Quote:
|
|
#8
|
|||
|
|||
|
Quote:
I didn't mention the ISO 8601 standard calendar: "Week 01 of a year is per definition the first week that has the Thursday in this year, which is equivalent to the week that contains the fourth day of January." Here is one reference I only wanted to point out that there are a number of ways of counting week numbers that I have personally experienced over the years, and that people dealing with calendars might want to be aware that there are lots of fine details to be considered to "get it right" --- where "right" depends on the requirements of the calendar's customer. (You, your company, your university instructor, or whoever wants the calendar.) Calendars are fun to play with (on what day of the week were you born?), and formulas such as Zeller's rule for calculating the day of the week for Gregorian calendar years are interesting (in my opinion) illustrations of C language integer division and modulus arithmetic. Regards, Dave |
Recent GIDBlog
Developing GUIs with wxPython (Part 2) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Re: Things to Avoid in C/C++ -- gets() , Part 1 | WaltP | C Programming Language | 5 | 21-Jun-2007 12:13 |
| C++ file I/O | CronoX | C++ Forum | 36 | 09-Mar-2004 17:28 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The