admin管理员组文章数量:1323586
I most likely suspect is not possible but I wanted to know If someone was has worked with customizing the calendar displayed on Jquery UI datepicker to the extend of changing the dates. Here is my situation: My pany uses a fiscal year instead of a calendar year where and it begins on a different day each year, I actually made an excel calendar in the mean time and I could use the principle on javascript, my question is if there is a way to set up an initial date on the calendar and start counting weeks from that day...
Example
Fiscal year starts on August 28 (sunday), given that :
AUG28-SEPT3 = FW1
SEPT4-SEPT10 = FW2
SEPT11-SEPT17 = FW3
.
.
.
and so on ...
i want to show a calendar with the week number starting on AUG28 2011 (fw1) and ending on aug25 2012 (fw52).
i already read the documentation and I cant' find anything related, if I was not clear enough please let me know so I can rephrase.
I most likely suspect is not possible but I wanted to know If someone was has worked with customizing the calendar displayed on Jquery UI datepicker to the extend of changing the dates. Here is my situation: My pany uses a fiscal year instead of a calendar year where and it begins on a different day each year, I actually made an excel calendar in the mean time and I could use the principle on javascript, my question is if there is a way to set up an initial date on the calendar and start counting weeks from that day...
Example
Fiscal year starts on August 28 (sunday), given that :
AUG28-SEPT3 = FW1
SEPT4-SEPT10 = FW2
SEPT11-SEPT17 = FW3
.
.
.
and so on ...
i want to show a calendar with the week number starting on AUG28 2011 (fw1) and ending on aug25 2012 (fw52).
i already read the documentation and I cant' find anything related, if I was not clear enough please let me know so I can rephrase.
Share Improve this question asked Oct 25, 2011 at 21:45 isJustMeisJustMe 5,4702 gold badges33 silver badges48 bronze badges 02 Answers
Reset to default 5You will have to create your own week calculation, see the docs for jQuery UI calculateWeek. Its a start, but not too helpful in those doc's. A little more useful was this blog post here.
Anyway here is the code I have managed to hack together, see the link below to see it working.
$("#mydatepicker").datepicker({
calculateWeek: fisc,
maxDate: '08/25/12',
minDate: '08/28/11',
showWeek: true
});
function fisc(date) {
var checkDate = new Date(date.getTime());
checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
var time = checkDate.getTime();
checkDate.setMonth(7);
checkDate.setDate(28);
var week = (Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 2);
if (week < 1) {
week = 52 + week;
}
return 'FW: '+week;
}
Click here to see this in action
I'm sure this probably isn't the perfect way to do this, but it seems to work for this time of night, hopefully it will point you in the correct direction.
Maybe you can try
$('.dateinput').datepicker({
dateFormat:'yy-mm-dd',
duration: 'normal',
changeMonth: true,
changeYear: true,
showWeek: true,
/*other options goes here...*/
calculateWeek: function(mydate){
return 'FW'+(
$.datepicker.iso8601Week(mydate + 1/*offset A*/)+1/*or offsetB*/
);
}
});
本文标签: javascriptCustomize Jquery UI DatepickerStack Overflow
版权声明:本文标题:javascript - Customize Jquery UI Datepicker - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742108538a2421136.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论