-2
$\begingroup$

I have a work schedule that uses a cycle like this:

Day 1: Morning shift

Day 2: Night shift

Day 3: Day off

Day 4: Morning shift

Day 5: Night shift

Days 6-8: 3 days off

Assuming today, May 4th is the 2nd day of a 3 days off in the cycle, which day will a 3 days off start in the last week of June (24th - 30th)?

Calendar screenshots you might need: May and June Calender screenshots

I just need a clear and simple way to be calculating this, other than reading round the calendar for many minutes. I tried getting help from AI chatbots, but each one yielded a different answer, often 1 or 2 days difference.

$\endgroup$
6
  • $\begingroup$ Call May 3 Day $1$, and mark off subsequent day $1's$ (eg May $11$ is again Day $1$) until a day $1$ falls in $24th-30th$ June slot $\endgroup$ Commented May 4 at 6:15
  • $\begingroup$ Two day $1$'s have a constant difference of days,i.e. 8. If you want to calculate the dates for all months, then it's best to make a program. $\endgroup$
    – Gwen
    Commented May 4 at 8:57
  • $\begingroup$ @trueblueanil, you mean manually cycling the calendar with the pattern until I arrive there. What's if it's more than 6 months away? Do I have to keep reading the calendar with the cycle for many minutes? I need a faster mathematical way to do this. That's why I shared the problem. 🤦 $\endgroup$ Commented May 4 at 15:52
  • $\begingroup$ I have posted the algebraic formula needed. It would be best to program it with data stored for days in various months $\endgroup$ Commented May 4 at 16:41
  • $\begingroup$ @Gwen you just gave me a new JavaScript Project idea. But the app I'm going to build still needs some logic and calculational steps, and that's exactly why I shared this problem here. I wonder why I'm getting downvotes instead. $\endgroup$ Commented May 4 at 17:15

1 Answer 1

0
$\begingroup$
  • Let $a$ = days left in month from zero day (the day you want to find), here $(31-3) = 28$
  • Let $b$ = days in skipped months, (here = $0$)
  • Let $c$ = start of date window in desired month, (here $24$)
  • Let $x = (a+b+c)mod\;8$ (here $28+0+24)\;mod\; 8 = 4$
  • Then desired date $=c+x = 24+4 = 28$ June
$\endgroup$
5
  • $\begingroup$ I don't really understand your a and b variables. Please, I need them clarified so I can test your solution for other cases to see if it's what I need. A concise explanation of your approach would also be appreciated. $\endgroup$ Commented May 4 at 17:25
  • $\begingroup$ [1] You are on second day of off on May 4, and want to find first day off later on, so first day off was May 3, and $a =31-3 =28$ days left in the month [2] If, say you wanted the date in July, skipped month would be June, so $b=30$ In your question, there is no skipped month, so $b=0$ $\endgroup$ Commented May 4 at 17:34
  • $\begingroup$ The solution really works. But I'd love to know how it works, like how you derived it; so I can use the same method to calculate for any other day in the cycle. $\endgroup$ Commented May 5 at 7:40
  • $\begingroup$ @HenryOzoani: Suppose that you wanted instead the last day of off some time later, Then the last day in the current cycle would be May $10$, so $a = 31 -10 =21$ days left in the month. $\endgroup$ Commented May 5 at 7:52
  • $\begingroup$ Okay. I see. The Formula makes it very easy than reading the calender cycle for many minutes. $\endgroup$ Commented May 5 at 10:20

Not the answer you're looking for? Browse other questions tagged .