Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Last week", "First week" and nth week of the month (as opposed to year) #4

Open
d1g opened this issue Jun 23, 2016 · 2 comments
Open

Comments

@d1g
Copy link
Collaborator

d1g commented Jun 23, 2016

Users were requesting support here. It is impossible to compute because:

  • Ambiguity in the definition
    • fractional weeks
      • (case 1) a week that starts with "start of the week" day (including incomplete 1-6 day weeks)
    • complete weeks
      • (case 2) a week that starts with "start of the week" day (including incomplete 1-6 day weeks) + missing days from the next month (in case of "last week")
      • (case 3) a week that contains all weekdays once (start and end date varies from year to year) and doesn't "wrap" in calendar presentation (country-dependant)
      • (case 4) an interval with last 7 days (last day of the month -7days)
  • Absolutely unclear semantic when "start of the week" is used (country-dependent); if a value was entered in one country, what users from other counties should see?
    • using "start of the week" of country where this object is located
    • using "start of the week" of country from their preferences

See also "The ISO 8601 definition for week 01 is the week with the year's first Thursday in it." - https://en.wikipedia.org/wiki/ISO_week_date#First_week

@ypid
Copy link
Member

ypid commented Jun 23, 2016

You are right. Without having more context. I would interpret this as something like Sep 15-Nov 15 Mo[-1],Mo[-1] +1 day,Mo[-1] +2 days,Mo[-1] +3 days,Mo[-1] +4 days,Mo[-1] +5 days 00:00-24:00 (+ the +6 days … +7 days). But the implementation for this is somehow broken. Also I limited the day offset to 6 because I did not think about such a use case yet.

@d1g
Copy link
Collaborator Author

d1g commented Jun 23, 2016

@ypid, you're talking about last complete week that is created by wrapping into next month (case 2).

I was able to get definition "the last full week in september from Monday through Saturday" (case 3).

Case 3 could be implemented using naive loop:

set nth_counter to 0;
Start with first day of the month, iterate +1 day until "calendar month" will change
if (current weekday of iteration is not equal to "start of the week") skip day(s) of incomplete week
if (current weekday of iteration is equal to "last day of the week") 
increment nth_counter and/or compute using nth_counter or store a nth recurring rule;

Note that "last full week in " and "first full week in " will resolve to 1 and 3-4 nth week, independently per each month+year.

Case 3 would result in 3-4 weeks, but I never seen any schedule "last full week in september from Monday through Saturday" Simpler "last Monday of the month" are far more common.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants