[英]jqm-calendar time format (24 hour default…would prefer 12 hour)
I am using jqm-calendar for my jquery mobile app. 我正在为我的jquery移动应用程序使用jqm-calendar。 Right now the default time format is 24 hours.
现在,默认时间格式为24小时。 I would like to change it to 12 hours.
我想将其更改为12小时。
Thank you. 谢谢。
https://github.com/JWGmeligMeyling/jqm-calendar https://github.com/JWGmeligMeyling/jqm-calendar
In file jw-jqm-cal.js 在文件jw-jqm-cal.js中
add this function: 添加此功能:
function tConvert (time) {
// Check correct time format and split into components
time = time.toString ().match (/^([01]\d|2[0-3])(:)([0-5]\d)(:[0-5]\d)?$/) || [time];
if (time.length > 1) { // If time format correct
time = time.slice (1); // Remove full string match value
time[5] = +time[0] < 12 ? ' AM' : ' PM'; // Set AM/PM
time[0] = +time[0] % 12 || 12; // Adjust hours
}
return time.join (''); // return adjusted time or original string
}
and insert this 2 lines in function plugin.settings.eventHandler.getEventsOnDay(begin, end, function(list_of_events) : 并在函数plugin.settings.eventHandler.getEventsOnDay(begin,end,function(list_of_events))中 插入 这两 行 :
beginTime =tConvert(beginTime );
endTime=tConvert(endTime);
EDIT 编辑
insert before: timeString = beginTime + "-" + endTime :** 在以下位置插入: timeString = beginTime +“-” + endTime:**
... ...
beginTime =tConvert(beginTime ); beginTime = tConvert(beginTime);
endTime=tConvert(endTime); endTime = tConvert(endTime);
timeString = beginTime + "-" + endTime, timeString = beginTime +“-” + endTime,
... ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.