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;
|
|
|
|
}
|
|
|
|
|
2023-02-17 15:19:49 +03:00
|
|
|
export function getCreatedDate(day) {
|
|
|
|
if (day) {
|
|
|
|
return `${new Date(day).getFullYear()}-${new Date(day).getMonth() + 1}-${new Date(day).getDate()}`
|
|
|
|
} else {
|
|
|
|
const date = new Date();
|
|
|
|
const dd = String(date.getDate()).padStart(2, '0');
|
|
|
|
const mm = String(date.getMonth() + 1).padStart(2, '0');
|
|
|
|
const yyyy = date.getFullYear();
|
|
|
|
return `${yyyy}-${mm}-${dd}`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2023-02-17 15:19:49 +03:00
|
|
|
export function getCorrectDate(day) {
|
2023-02-21 19:05:04 +03:00
|
|
|
const months = ['января', 'февраля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря']
|
|
|
|
return `${new Date(day).getDate()} ${months[new Date(day).getMonth()]} ${new Date(day).getFullYear()} года`
|
2023-02-17 15:19:49 +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
|
|
|
}
|