Home Reference Source Repository

# Function

 Static Public Summary public addDays(d: Date, days: number): Date 增加N天后的日期 public addMonths(d: Date, months: number): Date 增加N月后的日期 public format(date: Date, format: string): string 日期转字符串 public getContinuousFragments(begin: Date, end: Date, unit: string): Array 获取所允许的时间区间 public getDayOfWeek(d: Date): string 获取星期字符串 public getDaysInMonth(d: Date): number 获取某一月的天数 public getFirstDayOfMonth(d: Date): Date 获取某月第一天的日期对象 public getFullWeekArray(d: Date): Array 得到某一月所有天数按周组成若干个数组 第一周和最后一周不在本月的天数 public getNextTime(time: Date, unit: string): Date 处理时间对象，返回当前单位下下一个值 public getShortMonth(d: Date): string 获取月份字符串 public isAfterDate(d1: Date, d2: Date): boolean 判断两个日期对象的大小 public isAfterMonth(d1: Date, d2: Date): boolean 判断两个日期对象大小 public isBeforeDate(d1: Date, d2: Date): boolean 判断两个日期对象的大小 public isBeforeMonth(d1: Date, d2: Date): boolean 判断两个日期对象大小 public isDate(date: Date): boolean 是否为 Date 实例 public isEqualDate(d1: Date, d2: Date): boolean 判断两个日期对象是否为同一天 public isEqualMonth(d1: Date, d2: Date): boolean 判断两个日期对象是否在同一个月 public monthDiff(d1: Date, d2: Date): number 判断日期之间相差的月数 public normalize(time: Date, unit: string): Date 处理时间对象，只留下当前单位需要的部分 public parse(value: string, format: string): Date 字符串转日期 public yearDiff(d1: Date, d2: Date): number 判断日期之间相差的年数

## Static Public

### publicaddDays(d: Date, days: number): Date source

``import {addDays} from 'melon-calendar/src/util.js'``

#### Params:

 Name Type Attribute Description d Date 日期对象 days number 增加的天数

#### Return:

 Date 修改后的日期

### publicaddMonths(d: Date, months: number): Date source

``import {addMonths} from 'melon-calendar/src/util.js'``

#### Params:

 Name Type Attribute Description d Date 日期对象 months number 增加的月份数

#### Return:

 Date 修改后的日期对象

### publicformat(date: Date, format: string): string source

``import {format} from 'melon-calendar/src/util.js'``

#### Params:

 Name Type Attribute Description date Date 日期 format string 转换格式

#### Return:

 string 转换以后的日期

### publicgetContinuousFragments(begin: Date, end: Date, unit: string): Array<Date> source

``import {getContinuousFragments} from 'melon-calendar/src/UnitCalendar.js'``

#### Params:

 Name Type Attribute Description begin Date 起始时间 end Date 结束时间 unit string 单位

### publicgetDayOfWeek(d: Date): string source

``import {getDayOfWeek} from 'melon-calendar/src/util.js'``

#### Params:

 Name Type Attribute Description d Date 日期

### publicgetDaysInMonth(d: Date): number source

``import {getDaysInMonth} from 'melon-calendar/src/util.js'``

#### Params:

 Name Type Attribute Description d Date 日期

#### Return:

 number 当月的天数

### publicgetFirstDayOfMonth(d: Date): Date source

``import {getFirstDayOfMonth} from 'melon-calendar/src/util.js'``

#### Params:

 Name Type Attribute Description d Date Date对象

#### Return:

 Date 当月第一天日期

### publicgetFullWeekArray(d: Date): Array source

``import {getFullWeekArray} from 'melon-calendar/src/util.js'``

#### Params:

 Name Type Attribute Description d Date 日期

#### Return:

 Array 数据

### publicgetNextTime(time: Date, unit: string): Date source

``import {getNextTime} from 'melon-calendar/src/UnitCalendar.js'``

#### Params:

 Name Type Attribute Description time Date 时间 unit string 单位

### publicgetShortMonth(d: Date): string source

``import {getShortMonth} from 'melon-calendar/src/util.js'``

#### Params:

 Name Type Attribute Description d Date 日期

### publicisAfterDate(d1: Date, d2: Date): boolean source

``import {isAfterDate} from 'melon-calendar/src/util.js'``

#### Params:

 Name Type Attribute Description d1 Date 日期1 d2 Date 日期2

#### Return:

 boolean d1 > d2

### publicisAfterMonth(d1: Date, d2: Date): boolean source

``import {isAfterMonth} from 'melon-calendar/src/util.js'``

#### Params:

 Name Type Attribute Description d1 Date 日期1 d2 Date 日期2

#### Return:

 boolean d1 > d2

### publicisBeforeDate(d1: Date, d2: Date): boolean source

``import {isBeforeDate} from 'melon-calendar/src/util.js'``

#### Params:

 Name Type Attribute Description d1 Date 日期1 d2 Date 日期2

#### Return:

 boolean d1 < d2

### publicisBeforeMonth(d1: Date, d2: Date): boolean source

``import {isBeforeMonth} from 'melon-calendar/src/util.js'``

#### Params:

 Name Type Attribute Description d1 Date 日期1 d2 Date 日期2

#### Return:

 boolean d1 < d2

### publicisDate(date: Date): boolean source

``import {isDate} from 'melon-calendar/src/util.js'``

#### Params:

 Name Type Attribute Description date Date 一个对象

### publicisEqualDate(d1: Date, d2: Date): boolean source

``import {isEqualDate} from 'melon-calendar/src/util.js'``

#### Params:

 Name Type Attribute Description d1 Date 日期1 d2 Date 日期2

#### Return:

 boolean 是否为同一天

### publicisEqualMonth(d1: Date, d2: Date): boolean source

``import {isEqualMonth} from 'melon-calendar/src/util.js'``

#### Params:

 Name Type Attribute Description d1 Date 日期1 d2 Date 日期2

#### Return:

 boolean d1 = d2

### publicmonthDiff(d1: Date, d2: Date): number source

``import {monthDiff} from 'melon-calendar/src/util.js'``

#### Params:

 Name Type Attribute Description d1 Date 日期1 d2 Date 日期2

#### Return:

 number 相差的月数

### publicnormalize(time: Date, unit: string): Date source

``import {normalize} from 'melon-calendar/src/UnitCalendar.js'``

#### Params:

 Name Type Attribute Description time Date 时间 unit string 单位

### publicparse(value: string, format: string): Date source

``import {parse} from 'melon-calendar/src/util.js'``

#### Params:

 Name Type Attribute Description value string 日期字符串 format string 转换格式

#### Return:

 Date Date对象

### publicyearDiff(d1: Date, d2: Date): number source

``import {yearDiff} from 'melon-calendar/src/util.js'``

#### Params:

 Name Type Attribute Description d1 Date 日期1 d2 Date 日期2

#### Return:

 number 相差的年数