momentjs.comfunction textToDate(txt) {
if (txt == 'week') {
var startOfWeek = moment().startOf('week').format('DD.MM.YYYY');
var endOfWeek = moment().endOf('week').format('DD.MM.YYYY');
return startOfWeek + ' - ' + endOfWeek;
}
else if (txt == 'day') {
var startOfWeek = moment().startOf('day').format('DD.MM.YYYY');
return startOfWeek;
}
else if (txt == 'lastday') {
var startOfWeek = moment().subtract(1, 'day').startOf('day').format('DD.MM.YYYY');
return startOfWeek;
}
else if (txt == 'hour') {
var startOfWeek = moment().startOf('hour').format('DD.MM.YYYY HH:00');
var endOfWeek = moment().startOf('hour').add(1, 'hour').format('HH:00');
return startOfWeek + ' - ' + endOfWeek;
}
else if (txt == 'lastweek') {
var startOfWeek = moment().subtract(1, 'week').startOf('week').format('DD.MM.YYYY');
var endOfWeek = moment().subtract(1, 'week').endOf('week').format('DD.MM.YYYY');
return startOfWeek + ' - ' + endOfWeek;
}
else if (txt == 'month') {
var startOfWeek = moment().startOf('month').format('DD.MM.YYYY');
var endOfWeek = moment().endOf('month').format('DD.MM.YYYY');
return startOfWeek + ' - ' + endOfWeek;
}
else if (txt == 'lastmonth') {
var startOfWeek = moment().subtract(1, 'month').startOf('month').format('DD.MM.YYYY');
var endOfWeek = moment().subtract(1, 'month').endOf('month').format('DD.MM.YYYY');
return startOfWeek + ' - ' + endOfWeek;
}
else
return txt;
}