DATE : object
日期工具
Kind: global namespace
- DATE :
object
- .isWorkingTime(currentDate) ⇒
Boolean
- .isWorkingTimeByCalendar(currentDate, calendarId) ⇒
Boolean
- .getToday() ⇒
Date
- .getDay(date) ⇒
Integer
- .getMonth(date) ⇒
Integer
- .getYear(date) ⇒
Integer
- .parseDate(str, format) ⇒
Date
- .diffYears(startDate, endDate) ⇒
Integer
- .diffMonths(startDate, endDate) ⇒
Integer
- .diffDays(startDate, endDate) ⇒
Integer
- .adjustYear(date, num) ⇒
Date
- .adjustMonth(date, num) ⇒
Date
- .adjustDay(date, num) ⇒
Date
- .getCurDate(formatText) ⇒
String
- .format(date, formatText) ⇒
String
- .diffHours(startDate, endDate) ⇒
Integer
- .getWorkingDayCount(startDate, endDate) ⇒
Integer
- .getWorkingTimesCount(startDate, endDate) ⇒
Integer
- .isWorkingTime(currentDate) ⇒
DATE.isWorkingTime(currentDate) ⇒ Boolean
根据前台用户绑定的工作日历,判断当前时间currentDate是否为工作时间
Kind: static method of DATE
Returns: Boolean
- 是否为工作时间
true or false
Param | Type | Description |
---|---|---|
currentDate | Date |
日期型参数 |
DATE.isWorkingTimeByCalendar(currentDate, calendarId) ⇒ Boolean
根据工作日历,判断当前时间currentDate是否为工作时间
Kind: static method of DATE
Returns: Boolean
- 是否为工作时间
true or false
Param | Type | Description |
---|---|---|
currentDate | Date |
日期型参数 |
calendarId | String |
工作日历id |
DATE.getToday() ⇒ Date
获取当日日期
Kind: static method of DATE
Returns: Date
- 获取当日日期
DATE.getDay(date) ⇒ Integer
根据日期,获取日(几号)
Kind: static method of DATE
Returns: Integer
- 获取的日(几号)
Param | Type | Description |
---|---|---|
date | Date |
日期型参数 |
DATE.getMonth(date) ⇒ Integer
根据日期,获取月份
Kind: static method of DATE
Returns: Integer
- 获取的月份
Param | Type | Description |
---|---|---|
date | Date |
日期型参数 |
DATE.getYear(date) ⇒ Integer
根据日期,获取年份
Kind: static method of DATE
Returns: Integer
- 获取的年份
Param | Type | Description |
---|---|---|
date | Date |
日期型参数 |
DATE.parseDate(str, format) ⇒ Date
将字符串按给定格式转换为日期型
Kind: static method of DATE
Returns: Date
- 将字符串按给定格式转换为日期型
Param | Type | Description |
---|---|---|
str | String |
待转换的字符串,需符合format指定的格式 |
format | 日期格式 |
DATE.diffYears(startDate, endDate) ⇒ Integer
获取相隔年份数
Kind: static method of DATE
Returns: Integer
- 获取相隔年份数
Param | Type | Description |
---|---|---|
startDate | String |
“yyyy-MM-dd”格式的字符串 |
endDate | String |
“yyyy-MM-dd”格式的字符串 |
DATE.diffMonths(startDate, endDate) ⇒ Integer
获取相隔月份数
Kind: static method of DATE
Returns: Integer
- 获取相隔月份数
Param | Type | Description |
---|---|---|
startDate | String |
“yyyy-MM-dd”格式的字符串 |
endDate | String |
“yyyy-MM-dd”格式的字符串 |
DATE.diffDays(startDate, endDate) ⇒ Integer
获取相隔天数
Kind: static method of DATE
Returns: Integer
- 获取相隔天数
Param | Type | Description |
---|---|---|
startDate | String |
“yyyy-MM-dd”格式的字符串 |
endDate | String |
“yyyy-MM-dd”格式的字符串 |
DATE.adjustYear(date, num) ⇒ Date
校正年份
Kind: static method of DATE
Returns: Date
- 校正年份后的日期
Param | Type | Description |
---|---|---|
date | Date |
输入要校正的日期 |
num | Integer |
校正数,正负整数 |
DATE.adjustMonth(date, num) ⇒ Date
校正月份
Kind: static method of DATE
Returns: Date
- 校正月份后的日期
Param | Type | Description |
---|---|---|
date | Date |
输入要校正的日期 |
num | Integer |
校正数,正负整数 |
DATE.adjustDay(date, num) ⇒ Date
校正天数
Kind: static method of DATE
Returns: Date
- 校正天(日)后的日期
Param | Type | Description |
---|---|---|
date | Date |
输入要校正的日期 |
num | Integer |
校正数,正负整数 |
DATE.getCurDate(formatText) ⇒ String
按其参数指定的格式获取当前时间,并以字符串的形式返回
Kind: static method of DATE
Returns: String
- 按其参数指定的格式获取当前时间,并以字符串的形式返回
Param | Type | Description |
---|---|---|
formatText | String |
字符串型参数,指定需要显示的格式,如”yyyy-MM-dd HH:mm:ss” |
DATE.format(date, formatText) ⇒ String
按其参数指定的格式获取时间字符串
Kind: static method of DATE
Returns: String
- 字符串的形式返回
Param | Type | Description |
---|---|---|
date | Date |
日期型参数 |
formatText | String |
字符串型参数,指定需要显示的格式,如”yyyy-MM-dd HH:mm:ss” |
DATE.diffHours(startDate, endDate) ⇒ Integer
获取相隔小时数
Kind: static method of DATE
Returns: Integer
- 获取相隔小时数
Param | Type | Description |
---|---|---|
startDate | String |
开始时间,“yyyy-MM-dd HH:mm:ss”格式的字符串 |
endDate | String |
结束时间,“yyyy-MM-dd HH:mm:ss”格式的字符串 |
DATE.getWorkingDayCount(startDate, endDate) ⇒ Integer
获取相隔工作天数
Kind: static method of DATE
Returns: Integer
- 获取相隔工作天数
Param | Type | Description |
---|---|---|
startDate | String |
开始时间,“yyyy-MM-dd HH:mm:ss”格式的字符串 |
endDate | String |
结束时间,“yyyy-MM-dd HH:mm:ss”格式的字符串 |
DATE.getWorkingTimesCount(startDate, endDate) ⇒ Integer
获取相隔工作小时数
(注:若startDate或endDate小于当前年份前10年或大于当前年份后10年,返回0)
Kind: static method of DATE
Returns: Integer
- 获取相隔工作小时数
Param | Type | Description |
---|---|---|
startDate | String |
开始时间, “yyyy-MM-dd HH:mm:ss”格式的字符串 |
endDate | String |
结束时间,“yyyy-MM-dd HH:mm:ss”格式的字符串 |