strings.forEach(element => {
console.log(element);
let sel = element.querySelector('.selector');
if (sel.value === '0') {
error [element.name] = sel.name;
}
});
const compare = (dateStr, date) =>
Number(dateStr.split('-').reverse().join('')) <
date.getFullYear() * 10000 + (date.getMonth() + 1) * 100 + date.getDate()
console.log('22-02-2010', new Date('2010-02-25')) // true
console.log('22-02-2010', new Date('2010-02-22')) // false
const date = new Date('2005-10-02')
json.CardInfo.forEach(({Date: dateStr}) => compare(dateStr, date))
this.cities1 = [
{ city: 'Москва', cityCode: 'moskva54', views: '53М', visites: '1,1M', isActive: true },
{ city: 'Владимир', cityCode: 'vladimir', views: '23М', visites: '1,2M', isActive: false }
];
this.cities1 = {
'Москва': { city: 'Москва', cityCode: 'moskva54', views: '53М', visites: '1,1M', isActive: true },
'Владимир': { city: 'Владимир', cityCode: 'vladimir', views: '23М', visites: '1,2M', isActive: false }
};
function getIntervals (arr) {
const mlsInterval = 30 * 60 * 1000
const openHours = arr.filter(v => v.type === 'open').flatMap(v => {
const [d1, d2] = [new Date(v.from).getTime(), new Date(v.to).getTime()]
const length = Math.floor(( d2 - d1 ) / mlsInterval)
const hours = Array.from({ length }, (z, ind) => new Date(d1 + ind * mlsInterval))
return hours
})
const closeIntervals = arr.filter(v => v.type === 'closed').map(v =>
[new Date(v.from).getTime(), new Date(v.to).getTime()]
)
const result = openHours.filter(v =>
!closeIntervals.some(([start, stop]) => start <= v && stop > v)
).map(v => new Date(v).toString().match(/\d\d:\d\d:\d\d/g)[0])
return result
}