Browse Source

Merge pull request #247928 in DEC/fineui from master to feature/x

* commit 'b4c32ae3635644d66585d3a2cf2106dab27dae85':
  BI-133009 fix: 季末日期计算有误
research/test
superman 9 months ago
parent
commit
78f3b62364
  1. 22
      packages/fineui/src/core/func/date.js

22
packages/fineui/src/core/func/date.js

@ -56,7 +56,7 @@ export function getMonthDays(date, month = date.getMonth()) {
if (((0 === (year % 4)) && ((0 !== (year % 100)) || (0 === (year % 400)))) && month === 1) {
return 29;
}
return _MD[month];
}
@ -85,7 +85,7 @@ export function getDayOfYear(date) {
const now = getDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
const then = getDate(date.getFullYear(), 0, 0, 0, 0, 0);
const time = now - then;
return Math.floor(time / DAY);
}
@ -108,7 +108,7 @@ export function getWeekNumber(date) {
const ms = d.valueOf();
d.setMonth(0);
d.setDate(1);
return Math.floor((ms - d.valueOf()) / (7 * 864e5)) + 1;
}
@ -135,7 +135,7 @@ export function getOffsetQuarter(date, n) {
}
dt.setDate(day);
dt.setMonth(dt.getMonth() + parseInt(n, 10) * 3);
return dt;
}
@ -159,7 +159,7 @@ export function getQuarterStartMonth(date) {
if (nowMonth > 8) {
quarterStartMonth = 9;
}
return quarterStartMonth;
}
@ -179,8 +179,8 @@ export function getQuarterStartDate(date) {
*/
export function getQuarterEndDate(date) {
const quarterEndMonth = getQuarterStartMonth(date) + 2;
return getDate(date.getFullYear(), quarterEndMonth, getMonthDays(date));
return getDate(date.getFullYear(), quarterEndMonth, getMonthDays(date, quarterEndMonth));
}
/**
@ -198,7 +198,7 @@ export function getOffsetMonth(date, n) {
}
dt.setDate(day);
dt.setMonth(dt.getMonth() + parseInt(n, 10));
return dt;
}
@ -210,7 +210,7 @@ export function getOffsetMonth(date, n) {
export function getWeekStartDate(date) {
const w = date.getDay();
const startOfWeek = StartOfWeek % 7;
return getOffsetDate(date, _OFFSET[w < startOfWeek ? (7 + w - startOfWeek) : (w - startOfWeek)]);
}
@ -222,7 +222,7 @@ export function getWeekStartDate(date) {
export function getWeekEndDate(date) {
const w = date.getDay();
const startOfWeek = StartOfWeek % 7;
return getOffsetDate(date, _OFFSET[w < startOfWeek ? (7 + w - startOfWeek) : (w - startOfWeek)] + 6);
}
@ -349,7 +349,7 @@ export function print(date, str) {
if (!_global.navigator) {
return false;
}
return /Konqueror|Safari|KHTML/i.test(navigator.userAgent);
};

Loading…
Cancel
Save