简体   繁体   English

moment.js周数据生成问题

[英]moment.js week data generation issue

I am having a issue using the moment.js date library when generating week based data. 在生成基于周的数据时,使用moment.js日期库存在问题。

<script>

mo = moment().year(2012);
aa = mo.startOf('week').week(53).format("dddd, MMMM Do YYYY, h:mm:ss a");


mo1 = moment().year(2013);
cc = mo1.startOf('week').week(1).format("dddd, MMMM Do YYYY, h:mm:ss a");



document.write('start: ' + aa + ' ' + 'end: ' + cc);
</script>

The output in variables aa and cc are "Sunday, January 6th 2013, 12:00:00 am" even though the week numbers are 53 and 1 respectively. 即使星期数分别为53和1,变量aa和cc的输出仍为“ 2013年1月6日,星期日,凌晨12:00:00”。 Is this a bug in moment.js? 这是moment.js中的错误吗?

Regards. 问候。

Nope, that's not a bug. 不,那不是错误。 Years have only 52 weeks. 年只有52周。

moment.js may be internally discounting 52 weeks until it finds a number <= 52. moment.js可能会在内部打折52周,直到找到小于等于52的数字为止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM