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<Date>

获取所允许的时间区间

public

获取星期字符串

public

获取某一月的天数

public

获取某月第一天的日期对象

public

得到某一月所有天数按周组成若干个数组 第一周和最后一周不在本月的天数

public

getNextTime(time: Date, unit: string): Date

处理时间对象,返回当前单位下下一个值

public

获取月份字符串

public

判断两个日期对象的大小

public

判断两个日期对象大小

public

判断两个日期对象的大小

public

判断两个日期对象大小

public

isDate(date: Date): boolean

是否为 Date 实例

public

判断两个日期对象是否为同一天

public

判断两个日期对象是否在同一个月

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

public addDays(d: Date, days: number): Date source

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

增加N天后的日期

Params:

NameTypeAttributeDescription
d Date

日期对象

days number

增加的天数

Return:

Date

修改后的日期

public addMonths(d: Date, months: number): Date source

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

增加N月后的日期

Params:

NameTypeAttributeDescription
d Date

日期对象

months number

增加的月份数

Return:

Date

修改后的日期对象

public format(date: Date, format: string): string source

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

日期转字符串

Params:

NameTypeAttributeDescription
date Date

日期

format string

转换格式

Return:

string

转换以后的日期

public getContinuousFragments(begin: Date, end: Date, unit: string): Array<Date> source

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

获取所允许的时间区间

Params:

NameTypeAttributeDescription
begin Date

起始时间

end Date

结束时间

unit string

单位

Return:

Array<Date>

public getDayOfWeek(d: Date): string source

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

获取星期字符串

Params:

NameTypeAttributeDescription
d Date

日期

Return:

string

public getDaysInMonth(d: Date): number source

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

获取某一月的天数

Params:

NameTypeAttributeDescription
d Date

日期

Return:

number

当月的天数

public getFirstDayOfMonth(d: Date): Date source

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

获取某月第一天的日期对象

Params:

NameTypeAttributeDescription
d Date

Date对象

Return:

Date

当月第一天日期

public getFullWeekArray(d: Date): Array source

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

得到某一月所有天数按周组成若干个数组 第一周和最后一周不在本月的天数

Params:

NameTypeAttributeDescription
d Date

日期

Return:

Array

数据

public getNextTime(time: Date, unit: string): Date source

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

处理时间对象,返回当前单位下下一个值

Params:

NameTypeAttributeDescription
time Date

时间

unit string

单位

Return:

Date

public getShortMonth(d: Date): string source

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

获取月份字符串

Params:

NameTypeAttributeDescription
d Date

日期

Return:

string

public isAfterDate(d1: Date, d2: Date): boolean source

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

判断两个日期对象的大小

Params:

NameTypeAttributeDescription
d1 Date

日期1

d2 Date

日期2

Return:

boolean

d1 > d2

public isAfterMonth(d1: Date, d2: Date): boolean source

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

判断两个日期对象大小

Params:

NameTypeAttributeDescription
d1 Date

日期1

d2 Date

日期2

Return:

boolean

d1 > d2

public isBeforeDate(d1: Date, d2: Date): boolean source

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

判断两个日期对象的大小

Params:

NameTypeAttributeDescription
d1 Date

日期1

d2 Date

日期2

Return:

boolean

d1 < d2

public isBeforeMonth(d1: Date, d2: Date): boolean source

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

判断两个日期对象大小

Params:

NameTypeAttributeDescription
d1 Date

日期1

d2 Date

日期2

Return:

boolean

d1 < d2

public isDate(date: Date): boolean source

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

是否为 Date 实例

Params:

NameTypeAttributeDescription
date Date

一个对象

Return:

boolean

public isEqualDate(d1: Date, d2: Date): boolean source

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

判断两个日期对象是否为同一天

Params:

NameTypeAttributeDescription
d1 Date

日期1

d2 Date

日期2

Return:

boolean

是否为同一天

public isEqualMonth(d1: Date, d2: Date): boolean source

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

判断两个日期对象是否在同一个月

Params:

NameTypeAttributeDescription
d1 Date

日期1

d2 Date

日期2

Return:

boolean

d1 = d2

public monthDiff(d1: Date, d2: Date): number source

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

判断日期之间相差的月数

Params:

NameTypeAttributeDescription
d1 Date

日期1

d2 Date

日期2

Return:

number

相差的月数

public normalize(time: Date, unit: string): Date source

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

处理时间对象,只留下当前单位需要的部分

Params:

NameTypeAttributeDescription
time Date

时间

unit string

单位

Return:

Date

public parse(value: string, format: string): Date source

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

字符串转日期

Params:

NameTypeAttributeDescription
value string

日期字符串

format string

转换格式

Return:

Date

Date对象

public yearDiff(d1: Date, d2: Date): number source

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

判断日期之间相差的年数

Params:

NameTypeAttributeDescription
d1 Date

日期1

d2 Date

日期2

Return:

number

相差的年数