【发布时间】:2016-04-19 13:44:47
【问题描述】:
我有一个与 fullCalendar 控制有关的案例。我正在显示周一至周五的天数,并且添加了名为“添加新约会”的自定义按钮。当用户单击此按钮时,我们需要为月视图显示第一个星期一日期,如果是周视图,我们需要显示该周的第一个日期(星期一)。 '
到目前为止,我一直这样做,它适用于 IST 时区,但我的客户是 CST/EST,需要前一天。示例-如果我去二月并单击添加新的月视图,它应该是 02-02-2016 但它需要 01-31-2015。
function processDateTimeForNewCalendar() {
debugger;
var mondayForWeek = common.getMondayForCurrentWeek(new Date());
var dateHeader = $('div.fc-center h2').text();
var view = $('#calendar').fullCalendar('getView');
var date, sTime, eTime;
var currentDate = new Date();
if (view.name === 'month') {
debugger;
var currentMonth = dateHeader.split(" ")[0];
var currentYear = dateHeader.split(" ")[1];
var monthInNo = common.getMonthNumberByMonthName(currentMonth);
var temp = currentDate.getDate() + "-" + currentMonth + "-" + currentYear + " " + currentDate.getHours() + ":" + currentDate.getMinutes()
var tempDate = new Date(temp);
var mondayForWeek = common.getMondayForCurrentWeek(tempDate);
if ((currentDate.getMonth() + 1) === monthInNo)
date = new Date(currentDate.getDate() + "-" + currentMonth + "-" + currentYear + " " + currentDate.getHours() + ":" + currentDate.getMinutes());
if ((currentDate.getMonth() + 1) < monthInNo || (currentDate.getMonth() + 1) > monthInNo)
date = new Date(view.intervalStart);
sTime = moment(date).format("hh:mm A");
eTime = moment(date).add(30, 'minutes').format("hh:mm A");
}
if (view.name === 'agendaWeek' || view.name === 'agendaDay') {
date = new Date(view.start);
date = moment(date).format("MM/DD/YYYY");
sTime = moment(currentDate).format("hh:mm A");
eTime = moment(currentDate).add(30, 'minutes').format("hh:mm A");
}
$(CALENDAR.ApptStartDateById).val(moment(date).format("MM/DD/YYYY"));
$(CALENDAR.ApptEndDateById).val(moment(date).format("MM/DD/YYYY"));
$(CALENDAR.ApptStartTime).timepicker("setTime", sTime);
$(CALENDAR.ApptEndTime).timepicker("setTime", eTime);
$(CALENDAR.Duration).val(calculateDuration());
$(CALENDAR.ApptStartDateById).datepicker("update", date).datepicker('fill');
$(CALENDAR.ApptEndDateById).datepicker("update", date).datepicker('fill');
}
请帮我解决这个问题。
谢谢, 阿莫德
【问题讨论】:
-
您能否向我们提供您迄今为止所做的尝试?
-
@ChrisBeckett - 谢谢,是的。请再次检查问题。我已经把问题的代码放在那里了。我的另一个顾虑是我不允许 fullcalendar 使用 UTC,所以 timezone:'local' 在选项中设置。我可以关闭 $('#Calendar').fullCalendar('getView') 的时区吗;
标签: javascript jquery asp.net-mvc-5 fullcalendar