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

A few issues I encountered #27

Open
cameronjacobson opened this issue Aug 19, 2022 · 0 comments
Open

A few issues I encountered #27

cameronjacobson opened this issue Aug 19, 2022 · 0 comments

Comments

@cameronjacobson
Copy link

  1. package.json inside the 'backend' project points to dist/server.js. The file is located at dist/src/server.js. Not sure if the build is supposed to move the file to this location, or if your local configuration links this correctly, but it didn't in my case

  2. When the tests ran, a single test case failed. It was saying there are 21 workdays in March 2020 instead of 22. I traced this to a Daylight Savings issue. The calculateWorkDaysBetween method increments the time by exactly 86400000 milliseconds on each iteration. I noticed that the primary author is perhaps based in China, which might explain this since their browser may not trigger the same DST logic based on their locale. Date manipulation in the browser is tricky overall, but one quick fix way around this would be if you're instantiating the Date object using the new Date(year, monthIndex, day, hours, minutes, seconds) convention. This way, if you simply want to iterate day-by-day over an arbitrary date-range, you can just increment the 'days' parameter.
    ie. new Date(2020,2,70,0,0,0) == Sat May 09 2020 00:00:00

  3. I saw what appeared to be the same issue under Deployment Frequency result is not accurate. #10 . After a quick review of that I thought it might also be tied to the Daylight Savings issue.. In November, DST removes an hour as opposed to March, where an hour is added. This would cause an extra day, instead of the loss of a day in the calculation. Then I realized the Daylight Savings bug alone wouldn't explain why the date-range appears to have increased by 2 work days instead of 1. Instead this appears to be a combination of 2 separate issues. The Daylight Savings bug plus what appears to be a mistake in the 2020.json file. Granted, the holidays list isn't relevant to US, the following JSON entry appears to be adding an extra "day" into the calculation of the total number of work days in Oct 2020. By my calculation if you account for all the holidays from the json file, the total number of work days would be 16, but because of this extra entry, the method provides a result of 17. This is evident by the unit test which is looking for 2020-10-01 to 2020-10-31 to calculate a total of 17 work days in this date-range.

        {
            "name": "国庆节、中秋节",
            "date": "2020-10-10",
            "isOffDay": false
        }

I did confirm that when "isOffDay" is false, the logic of the method does add an extra day into the returned result. I stopped testing at this point. The evidence appears sufficient to point to this combination of issues as causing the problem reported in #10 .

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

No branches or pull requests

1 participant