简体   繁体   中英

moment.js week data generation issue

I am having a issue using the moment.js date library when generating week based data.

<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. Is this a bug in moment.js?

Regards.

Nope, that's not a bug. Years have only 52 weeks.

moment.js may be internally discounting 52 weeks until it finds a number <= 52.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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