Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 704117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:54:21+00:00 2026-05-14T03:54:21+00:00

This is a bit odd, but is it possible to use an NSCalendar (or

  • 0

This is a bit odd, but is it possible to use an NSCalendar (or any component, for that matter) to figure out what the date of the next “first tuesday of the month” would be?

For example, today is Thursday March 25, 2010. The next “first tuesday of the month” would be on April 6. Likewise, if I were looking for the next “first tuesday of the month” on April 1, it would still be on April 6.

How would you do this?

Thanks very much!!!!!

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:54:21+00:00Added an answer on May 14, 2026 at 3:54 am

    The code below calculates the first Tuesday of a given month/year combination. It’s written in MacRuby because that is what I just tried it with, but you should have no problems to convert it to proper Objective-C, it’s just a different syntax (I love MacRuby for quickly trying out an idea):

    dc = NSDateComponents.alloc.init
    # Set month to April 2010
    dc.setYear 2010
    dc.setMonth 4
    
    dc.setWeekday 3 # 1 = Sunday, 2 = Monday, ...
    dc.setWeekdayOrdinal 1 # We want the first weekday of the month
    
    cal = NSCalendar.alloc.initWithCalendarIdentifier NSGregorianCalendar
    date = cal.dateFromComponents dc
    date.description # => "2010-04-06 00:00:00 +0200"
    

    I leave it to you to determine the “next first Tuesday” from a given date: do the calculation for the month of the current date first and if the result is in the past, do it again for the following month. Use -[NSCalendar components:fromDate:] to get the month/day combo of a given NSDate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might be a little bit odd question, but Im trying to figure out
This is a bit odd perhaps, but wondering if it is possible to achieve
This is a bit of a an odd question but I'll make it out
This might sound a bit of an odd question but I know what I
This may seem a bit odd, but I really need to create a workaround
I know this is a bit odd but bear with me. I have a
SO this is a bit of an odd request but hoping someone on here
This is a bit of an odd situation. Here's what's happening. So, we have
This is a bit of an odd question and more of a though experiment
This bit of code comes with new classes that are subclasses of UITableViewController... -

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.