|
|
@@ -3,25 +3,6 @@ import { DateInfo } from "../models/DateInfo";
|
|
|
// 星期中文映射表
|
|
|
export const WEEK_MAP = ['日', '一', '二', '三', '四', '五', '六'];
|
|
|
|
|
|
-/**
|
|
|
- * 创建一个日期信息对象
|
|
|
- * @param date 日期对象
|
|
|
- * @returns DateInfo 对象
|
|
|
- */
|
|
|
-function createDateInfo(date: Date): DateInfo {
|
|
|
- const year = date.getFullYear();
|
|
|
- const month = date.getMonth() + 1;
|
|
|
- const day = date.getDate();
|
|
|
- const week = WEEK_MAP[date.getDay()];
|
|
|
-
|
|
|
- return {
|
|
|
- year: year,
|
|
|
- month: month,
|
|
|
- day: day,
|
|
|
- week: week,
|
|
|
- id: new Date(date)
|
|
|
- };
|
|
|
-}
|
|
|
|
|
|
|
|
|
export class DateUtils {
|
|
|
@@ -86,7 +67,7 @@ export class DateUtils {
|
|
|
|
|
|
for (let i = 0; i < count; i++) {
|
|
|
// 添加日期信息到数组
|
|
|
- dateArray.push(createDateInfo(currentDate));
|
|
|
+ dateArray.push(DateUtils.createDateInfo(currentDate));
|
|
|
|
|
|
// 日期减1天(向前)
|
|
|
currentDate.setDate(currentDate.getDate() - 1);
|
|
|
@@ -125,7 +106,7 @@ export class DateUtils {
|
|
|
}
|
|
|
|
|
|
// 添加日期信息到数组
|
|
|
- dateArray.push(createDateInfo(currentDate));
|
|
|
+ dateArray.push(DateUtils.createDateInfo(currentDate));
|
|
|
|
|
|
// 日期加1天(向后)
|
|
|
currentDate.setDate(currentDate.getDate() + 1);
|
|
|
@@ -133,5 +114,25 @@ export class DateUtils {
|
|
|
|
|
|
return dateArray;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建一个日期信息对象
|
|
|
+ * @param date 日期对象
|
|
|
+ * @returns DateInfo 对象
|
|
|
+ */
|
|
|
+ static createDateInfo(date: Date): DateInfo {
|
|
|
+ const year = date.getFullYear();
|
|
|
+ const month = date.getMonth() + 1;
|
|
|
+ const day = date.getDate();
|
|
|
+ const week = WEEK_MAP[date.getDay()];
|
|
|
+
|
|
|
+ return {
|
|
|
+ year: year,
|
|
|
+ month: month,
|
|
|
+ day: day,
|
|
|
+ week: week,
|
|
|
+ id: new Date(date)
|
|
|
+ };
|
|
|
+ }
|
|
|
}
|
|
|
|