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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:00:53+00:00 2026-06-10T15:00:53+00:00

I’m stuck with a strange bug in my code. Actually I modified legacy code

  • 0

I’m stuck with a strange bug in my code. Actually I modified legacy code which wasn’t really clear and ended up with this problem. You can see an example live here in a fiddle.

Basically I’ve got a calendar and I need to stretch multi day events so that they span the correct number of days. Everything works but for one case: if the first day of the month is the first day of the week. In that case an event that span multiple days is one day shorter only for the first week. I solved this by using a workaround

// There is a bug that happens only when the first day of the 
// month is the first day of the week. In that case events that start on the first of the month
// or multy day events that span from the previous month end up being a day too short in the 
// first week. So for example an event that lasted the full month was only six days in the first week.
// This workaround works for me, couldn't understand what's wrong.
// if (startDay === 1 && daysFirstWeek === 7) {
   // days += 1;
// }

If you uncomment the lines everything works, but obviously this is not a solution.

I need some fresh eyes on this matter, probably it’s wrong the concept that lies beneath the whole thing and I should start from scratch, but I’m annoyed when I can’t find a solution.

  • 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-06-10T15:00:54+00:00Added an answer on June 10, 2026 at 3:00 pm

    UPDATED

    OK, got it this time. Your check is wrong in the other condition:

            if (cellNum !== 0) {
                // Extend initial event bar to the end of first (!) week.
                if (curLine === 0) {
                    days++;
                }
            } else if (day > startDay && daysLeft !== 0) {    // WRONG CHECK HERE!
    

    day > startDay needs to be day >= startDay. Then all works correctly.

    This is the case because of the loop initial check:

    if (day >= startDay && day <= endDay) {
    

    With the later check being day > startDay, it misses adding the first cell that comes along to days, and, curLine does not get incremented on time. The first cell from the next row ends up being processed with curLine being 1 less than it should. If you console log the curLine and cellNum, you will see they go like this and don’t line up where they should. With the fix, the processing goes into the inner condition on the first cell like it should.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I used javascript for loading a picture on my website depending on which small
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't

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.