计算财政年度周数的 Javascript 算法
我一直在寻找一种 Javascript 算法,它可以为我提供自定义会计年度内给定日期对象的周数。我公司的财政年度从 9 月 1 日开始,到 8 月 31 日结束。
假设今天恰好是 9 月 1 日,我将一个新实例化的 Date 对象传递给此函数;我希望它返回 1。
希望有人能够帮助我。
I have been looking for a Javascript algorithms that gives me the week number of a given Date object within a custom fiscal year. The fiscal year of my company starts on 1 September and ends on 31 August.
Say today happens to be September 1st and I pass in a newly instanced Date object to this function; I would expect it to return 1.
Hopefully someone will be able to help me with it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您想要日期为 X 的财政年度。
应该可以了 - 也许新年前后会出现问题,但我想很容易弄清楚。
要获得任何一年内的周数,有很多解决方案。这只是其中之一: http://syn.ac/tech /19/get-the-weeknumber-with-javascript/
Say you want the fiscal year for date X.
That should do it - maybe there's a problem around new year, but easy enough to figure out I guess.
To get the week number within any year, there are plenty of solutions. Here's just one of them: http://syn.ac/tech/19/get-the-weeknumber-with-javascript/