如果是星期天,则看不到每个月的1号 [英] Can't see the 1st in each month, if it is Sunday

查看:136
本文介绍了如果是星期天,则看不到每个月的1号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好,关于日历的最后一个问题(承诺)在 http://testingbar.atspace.com/index2.htm [^ ]

八月从星期日开始.如果按Nästa"直到到达"Augusti",您将注意到数字1不可见.从星期日开始的每个月都是一样的.但是,如果月份从周末的另一天开始,则看起来正确.如何纠正呢? :confused:

Ok, the last question (promise) about the calendar at http://testingbar.atspace.com/index2.htm[^]

August starts with a Sunday. If you press "Nästa" until you reach "Augusti", then you''ll notice that the number 1 is not visible. It is the same with every month that begins with a Sunday. However, if the month starts with another day in the weekend it looks correct. How to correct this? :confused:

推荐答案

您从何处获得此日历,为什么要要求我们为您重写?答案显然是浏览代码,弄清楚错误是什么,然后修复它.可能是舍入错误吗?
Where did you get this calendar and why are you asking us to rewrite it for you ? The answer is obviously to look through the code, work out what the bug is, and fix it. Could it be a rounding error ?


我认为Date.getDay()函数存在问题.我认为星期日返回0,这可能会影响您的以下逻辑.

我快速浏览并发现了以下内容:
I think it''s a problem with the Date.getDay() function. I believe it returns 0 for sundays which may be throwing your following logic off.

I had a quick look and found this:
Line 89:
firstDay = firstDate.getDay() + 0;

忽略+0绝对无用的事实.您所需要的只是在它下面的行上有一点点条件,例如:

Ignore the fact that +0 is doing absolutely nothing useful. All you need is a little condition on the line underneath it like:

firstDay = ( firstDay == 0 ) ? 7 : firstDay;


这篇关于如果是星期天,则看不到每个月的1号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆