feat(laydate): 优化 holidays 日期对比 (#1719)

* feat(laydate): 优化 holidays 日期对比

* update code
pull/1740/head
morning-star 8 months ago committed by GitHub
parent b5cc9d8787
commit b7686d2228
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1074,9 +1074,23 @@
if(layui.type(options.holidays) !== 'array') return that; if(layui.type(options.holidays) !== 'array') return that;
var isEquals = function(ymdStr1, ymdStr2){
var ymd1 = ymdStr1.split('-');
var ymd2 = ymdStr2.split('-');
lay.each(ymd1, function(i,v){
ymd1[i] = parseInt(v, 10);
})
lay.each(ymd2, function(i,v){
ymd2[i] = parseInt(v, 10);
})
return ymd1.join('-') === ymd2.join('-');
}
lay.each(options.holidays, function(idx, item) { lay.each(options.holidays, function(idx, item) {
lay.each(item, function(i, dayStr) { lay.each(item, function(i, dayStr) {
if(dayStr === td.attr('lay-ymd')){ if(isEquals(dayStr, td.attr('lay-ymd'))){
td.find('div').html('<span class="laydate-day-holidays"' + ( td.find('div').html('<span class="laydate-day-holidays"' + (
type[idx] ? ('type="'+ type[idx] +'"') : '' type[idx] ? ('type="'+ type[idx] +'"') : ''
) + '>' + YMD[2] + '</span>'); ) + '>' + YMD[2] + '</span>');

Loading…
Cancel
Save