# Help required for Calendar

Mandar Puranik
Ranch Hand
Posts: 35
Hi Friends,
Please can you help me ?
I need to do following.
I have to find out all(or 1st and 3rd) Saturdays and Sundays in
an year.
For that, I want to set the calendar date to 1st Jan of that year,
so that I can start from there and then find the required Saturdays and
Sundays.
How should I proceed ?
Thanks
Mandar

David Peterson
author
Ranch Hand
Posts: 154
Personally, I would use a "brute force and ignorance" approach... just iterate through each day of the year, and check whether it's a Saturday or Sunday.

Obviously if you want 1st/3rd weekends you're going to need a bit more logic in there. You may also need to decide whether if the first day of a month begins on a Sunday that counts as the "1st Sunday" of the month, or whether you are talking about Sat+Sun together.
Hope this helps get you started.
David Peterson

Sonny Pondrom
Ranch Hand
Posts: 128
You might want to make a calender object that has a method that would return a list of dates for a given year and the target day of the week needed.
The day offset would be a number from the first day of the year to the target day of the week.
Then you could make a list of Lunar calender days by accumulating in 14 day increments until the total is more than 366.
Then you could make a method that changed a lunar date to a Gregorian date.
And finally convert the Lunar list to make your output list.
Hope this helps.

Mandar Puranik
Ranch Hand
Posts: 35
Hi David and Sonny,
Thanks for you advice. It helped me a lot.
I used the advice you two gave.
I just set the day of the calendar to the 1st Jan of that year.
Then iterated to get all the sundays and saturdays.
Its working perfectly correct.
Thanks and Warm Regards
Mandar