Commit 15340644 by Leo Zheng

修改日期格式

parent 04571970
...@@ -82,7 +82,16 @@ protected getListCount(list: string[], target: string, data: any, year: string) ...@@ -82,7 +82,16 @@ protected getListCount(list: string[], target: string, data: any, year: string)
const count = this.registerItems(list); const count = this.registerItems(list);
data.forEach(row => { data.forEach(row => {
const rowDate = excelSerialToJSDate(row['创建时间']); // const rowDate = excelSerialToJSDate(row['创建时间']);
let rowDate: any = 0;
if (typeof (row['创建时间']) == "number") {
rowDate = excelSerialToJSDate(row['创建时间']);
// console.log("from if", row['创建时间']);
}
else {
rowDate = row['创建时间'];
// console.log(rowDate);
}
const rowYear = rowDate.getFullYear(); const rowYear = rowDate.getFullYear();
if (rowYear == targetYear) { if (rowYear == targetYear) {
count.set(row[target], (count.get(row[target]) || 0) + 1); count.set(row[target], (count.get(row[target]) || 0) + 1);
......
...@@ -31,6 +31,7 @@ export class eventMonthDistributionStrategy extends abstractDataStrategyRight { ...@@ -31,6 +31,7 @@ export class eventMonthDistributionStrategy extends abstractDataStrategyRight {
* @returns 事件按月分布计数的映射。 * @returns 事件按月分布计数的映射。
*/ */
private getEventMonthDistribution(data: any, year: string) { private getEventMonthDistribution(data: any, year: string) {
const currentYear = new Date().getFullYear(); const currentYear = new Date().getFullYear();
const targetYear = year === 'thisyear' ? currentYear : currentYear - 1; const targetYear = year === 'thisyear' ? currentYear : currentYear - 1;
...@@ -41,7 +42,13 @@ export class eventMonthDistributionStrategy extends abstractDataStrategyRight { ...@@ -41,7 +42,13 @@ export class eventMonthDistributionStrategy extends abstractDataStrategyRight {
} }
data.forEach(row => { data.forEach(row => {
const rowDate = excelSerialToJSDate(row['创建时间']); let rowDate: any = 0;
if (typeof (row['创建时间']) == "number") {
rowDate = excelSerialToJSDate(row['创建时间']);
}
else {
rowDate = row['创建时间'];
}
rowDate.setHours(rowDate.getHours() - eventMonthDistributionStrategy.TIMEDIFFERENCE); rowDate.setHours(rowDate.getHours() - eventMonthDistributionStrategy.TIMEDIFFERENCE);
const rowYear = rowDate.getFullYear(); const rowYear = rowDate.getFullYear();
const rowMonth = rowDate.getMonth() + 1; // getMonth() returns 0-11 const rowMonth = rowDate.getMonth() + 1; // getMonth() returns 0-11
......
...@@ -42,8 +42,16 @@ export class getEventCountByYearStrategy extends abstractDataStrategyRight { ...@@ -42,8 +42,16 @@ export class getEventCountByYearStrategy extends abstractDataStrategyRight {
data.forEach(row => { data.forEach(row => {
const rawDate = row['创建时间']; const rawDate = row['创建时间'];
const rowDate = excelSerialToJSDate(rawDate); // const rowDate = excelSerialToJSDate(rawDate);
let rowDate: any = 0;
if (typeof (row['创建时间']) == "number") {
rowDate = excelSerialToJSDate(row['创建时间']);
console.log("from if", row['创建时间']);
}
else {
rowDate = row['创建时间'];
console.log(rowDate);
}
let rowYear = 0; let rowYear = 0;
if (!isNaN(rowDate.getTime())) { if (!isNaN(rowDate.getTime())) {
try { try {
...@@ -53,7 +61,7 @@ export class getEventCountByYearStrategy extends abstractDataStrategyRight { ...@@ -53,7 +61,7 @@ export class getEventCountByYearStrategy extends abstractDataStrategyRight {
console.log('Error getting year:', e); console.log('Error getting year:', e);
} }
} else { } else {
console.log('Invalid Date:', rawDate.getTime()); // console.log('Invalid Date:', rawDate.getTime());
} }
if (rowYear == targetYear) { if (rowYear == targetYear) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment