2021-06-22 18:00:52 +03:00
|
|
|
import moment from 'moment';
|
|
|
|
import 'moment/locale/ru';
|
|
|
|
|
|
|
|
export function calendarHelper(value) {
|
2021-06-17 18:21:48 +03:00
|
|
|
const startDay = value.clone().startOf('month').startOf('week').startOf('day');
|
|
|
|
const endDay = value.clone().endOf('month').endOf('week');
|
|
|
|
|
|
|
|
const day = startDay.clone().subtract(1, 'day');
|
|
|
|
|
|
|
|
const calendar = [];
|
|
|
|
|
|
|
|
while (day.isBefore(endDay, 'day')) {
|
|
|
|
calendar.push(
|
2021-06-18 17:16:08 +03:00
|
|
|
Array(1)
|
2021-06-17 18:21:48 +03:00
|
|
|
.fill(0)
|
|
|
|
.map(() => day.add(1, 'day').clone())
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return calendar;
|
|
|
|
}
|
2021-06-22 18:00:52 +03:00
|
|
|
|
2022-12-26 15:12:01 +03:00
|
|
|
export function getReports(value) {
|
|
|
|
const startDay = value.clone().startOf('month').startOf('week').startOf('day');
|
|
|
|
const reportsStart = `${new Date(startDay).getFullYear()}-${new Date(startDay).getMonth() + 1}-${new Date(startDay).getDate()}`
|
|
|
|
const endDay = value.clone().endOf('month').endOf('week');
|
|
|
|
const reportsEnd = `${new Date(endDay).getFullYear()}-${new Date(endDay).getMonth() + 1}-${new Date(endDay).getDate()}`
|
|
|
|
const getReports = `fromDate=${reportsStart}&toDate=${reportsEnd}`
|
|
|
|
|
|
|
|
return getReports;
|
|
|
|
}
|
|
|
|
|
2021-06-22 18:00:52 +03:00
|
|
|
export function currentMonth() {
|
|
|
|
const currentMonth = moment().format('MMMM');
|
|
|
|
|
|
|
|
return currentMonth.charAt(0).toUpperCase() + currentMonth.slice(1);
|
|
|
|
}
|
|
|
|
|
2021-06-23 12:48:02 +03:00
|
|
|
export function currentMonthAndDay(day) {
|
|
|
|
return day.format('D MMMM');
|
|
|
|
}
|
2021-06-22 18:00:52 +03:00
|
|
|
|
2021-06-23 12:48:02 +03:00
|
|
|
export function currentMonthAndDayReportPage() {
|
2021-06-22 18:00:52 +03:00
|
|
|
return moment().format('D MMMM');
|
2022-12-26 15:12:01 +03:00
|
|
|
}
|