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 7181971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:40:10+00:00 2026-05-28T17:40:10+00:00

I can only find algorithm for getting ISO 8601 week (week starts on a

  • 0

I can only find algorithm for getting ISO 8601 week (week starts on a Monday).

However, the iCal spec says

A week is defined as a seven day period, starting on the day of the
week defined to be the week start (see WKST). Week number one of the
calendar year is the first week that contains at least four (4) days
in that calendar year.

Therefore, it is more complex than ISO 8601 since the start of week can be any day of the week.

Is there an algorithm to determine what is the week number of a date, with a custom start day of week?

or… is there a function in iCal4j that does this? Determine a weekno from a date?

Thanks!

p.s. Limitation: I’m using a JVM language that cannot extend a Java class, but I can invoke Java methods or instantiate Java classes.

  • 1 1 Answer
  • 0 Views
  • 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-28T17:40:10+00:00Added an answer on May 28, 2026 at 5:40 pm
    1. Let daysInFirstWeek be the number of days on the first week of the year that are in January. Week starts on a WKST day. (e.g. if Jan 1st is a WKST day, return 7)

    2. Set dayOfYear to the n-th days of the input date’s year (e.g. Feb 1st = 32)

    3. If dayOfYear is less than or equal to daysInFirstWeek

      3.1. if daysInFirstWeek is greater than or equal to 4, weekNo is 1, skip to step 5.

      3.2. Let daysInFirstWeekOfLastYear be the number of days on the first week of the previous year that are in January. Week starts on a WKST day.

      3.3. if daysInFirstWeekOfLastYear is 4 or last year is Leap year and daysInFirstWeekOfLastYear is 5, weekNo is 53, otherwise weekNo is 52, skip to step 5.

    4. Set weekNo to ceiling((dayOfYear - daysInFirstWeek) / 7)

      4.1. if daysInFirstWeek greater than or equal to 4, increment weekNo by 1

      4.2. if daysInFirstWeek equal 53 and count of days on the first week (starting from WKST) of January in the year of inputDate‘s year + 1 is greater than or equal to 4, set weekNo to 1

    5. return weekNo

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

Sidebar

Related Questions

I can only find asynchronous iPad/objective C HTTP examples. How do I do a
I've searched the web, and I can only find marketing material on .net 4.
I'm trying to add Jumplist support to my app, but I can only find
[The only similar question I can find was answered long ago and contains a
I can't find much information on const_cast . The only info I could find
This is only tangentially a programming question. Where can I find a simple-to-parse list
Can someone hep me find an algorithm for a recursive function func(int k) to
Can anyone help me find an optimal Dynamic programming algorithm for this problem On
I'm trying to find this algorithm on C++ in .NET but can't, I found
I can only think of Peek() and ReadNoAdvance() atm, but I wonder if there

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.