Skip to content

Commit e8b36a6

Browse files
committed
releases 3.8.0
1 parent bafd5e3 commit e8b36a6

14 files changed

Lines changed: 381 additions & 9 deletions

func/date.d.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
export * from './getWhatYear'
22
export * from './getWhatQuarter'
33
export * from './getWhatMonth'
4+
export * from './getWhatWeek'
45
export * from './getWhatDay'
6+
export * from './getWhatHours'
7+
export * from './getWhatMinutes'
8+
export * from './getWhatSeconds'
59
export * from './toStringDate'
610
export * from './toDateString'
711
export * from './now'
812
export * from './timestamp'
913
export * from './isValidDate'
1014
export * from './isDateSame'
11-
export * from './getWhatWeek'
1215
export * from './getYearDay'
1316
export * from './getYearWeek'
1417
export * from './getMonthWeek'

func/date.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
var getWhatYear = require('./getWhatYear')
44
var getWhatQuarter = require('./getWhatQuarter')
55
var getWhatMonth = require('./getWhatMonth')
6+
var getWhatWeek = require('./getWhatWeek')
67
var getWhatDay = require('./getWhatDay')
8+
var getWhatHours = require('./getWhatHours')
9+
var getWhatMinutes = require('./getWhatMinutes')
10+
var getWhatSeconds = require('./getWhatSeconds')
711
var toStringDate = require('./toStringDate')
812
var toDateString = require('./toDateString')
913
var now = require('./now')
1014
var timestamp = require('./timestamp')
1115
var isValidDate = require('./isValidDate')
1216
var isDateSame = require('./isDateSame')
13-
var getWhatWeek = require('./getWhatWeek')
1417
var getYearDay = require('./getYearDay')
1518
var getYearWeek = require('./getYearWeek')
1619
var getMonthWeek = require('./getMonthWeek')
@@ -30,6 +33,9 @@ var dateExports = {
3033
getWhatMonth: getWhatMonth,
3134
getWhatWeek: getWhatWeek,
3235
getWhatDay: getWhatDay,
36+
getWhatHours: getWhatHours,
37+
getWhatMinutes: getWhatMinutes,
38+
getWhatSeconds: getWhatSeconds,
3339
getYearDay: getYearDay,
3440
getYearWeek: getYearWeek,
3541
getMonthWeek: getMonthWeek,

func/getWhatDay.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
/**
22
* 返回前几天或后几天的日期
33
* @param date 字符串/日期/时间戳
4-
* @param offset 天偏移量(默认0)、前几天、后几天
4+
* @param offset 指定小时(null默认当前分)、0时(first)、23时(last)
55
*/
66
export declare function getWhatDay(date: string | Date | number, offset: number): Date;
77

88
/**
99
* 返回前几天或后几天的日期
1010
* @param date 字符串/日期/时间戳
1111
* @param offset 天偏移量(默认0)、前几天、后几天
12-
* @param mode 获取时间:日初(first)、日末(last)
12+
* @param mode 指定小时(null默认当前分)、0时(first)、23时(last)
1313
*/
1414
export declare function getWhatDay(date: string | Date | number, offset: number, mode: 'first' | 'last'): Date;
1515

func/getWhatDay.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ var isValidDate = require('./isValidDate')
1313
* 返回前几天或后几天的日期
1414
*
1515
* @param {Date} date 日期或数字
16-
* @param {Number} offset 天(默认当天)、前几天、后几天
17-
* @param {String} mode 获取时分秒(null默认当前时分秒)、日初(first)、日末(last)
16+
* @param {Number} offset 天偏移量(默认0)、前几天、后几天
17+
* @param {String} mode 指定小时(null默认当前分)、0时(first)、23时(last)
1818
* @return {Date}
1919
*/
2020
function getWhatDay (date, offset, mode) {

func/getWhatHours.d.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* 返回前几小时或后几小时的日期
3+
* @param date 字符串/日期/时间戳
4+
* @param offset 小时偏移量(默认0)、前几小时、后几小时
5+
*/
6+
export declare function getWhatHours(date: string | Date | number, offset: number): Date;
7+
8+
/**
9+
* 返回前几小时或后几小时的日期
10+
* @param date 字符串/日期/时间戳
11+
* @param offset 小时偏移量(默认0)、前几小时、后几小时
12+
* @param mode 指定分钟(null默认当前分)、0分(first)、59分(last)
13+
*/
14+
export declare function getWhatHours(date: string | Date | number, offset: number, mode: 'first' | 'last'): Date;
15+
16+
declare module './ctor' {
17+
interface XEUtilsMethods {
18+
getWhatHours: typeof getWhatHours;
19+
}
20+
}
21+
22+
export default getWhatHours

func/getWhatHours.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
var staticStrFirst = require('./staticStrFirst')
2+
var staticStrLast = require('./staticStrLast')
3+
var staticParseInt = require('./staticParseInt')
4+
5+
var helperGetDateFullYear = require('./helperGetDateFullYear')
6+
var helperGetDateMonth = require('./helperGetDateMonth')
7+
var helperGetDateTime = require('./helperGetDateTime')
8+
9+
var toStringDate = require('./toStringDate')
10+
var isValidDate = require('./isValidDate')
11+
12+
/**
13+
* 返回前几小时或后几小时的日期
14+
*
15+
* @param {Date} date 日期或数字
16+
* @param {Number} offset 小时偏移量(默认0)、前几小时、后几小时
17+
* @param {String} mode 指定分钟(null默认当前分)、0分(first)、59分(last)
18+
* @return {Date}
19+
*/
20+
function getWhatHours (date, offset, mode) {
21+
date = toStringDate(date)
22+
if (isValidDate(date) && !isNaN(offset)) {
23+
date.setHours(date.getHours() + staticParseInt(offset))
24+
if (mode === staticStrFirst) {
25+
return new Date(helperGetDateFullYear(date), helperGetDateMonth(date), date.getDate(), date.getHours())
26+
} else if (mode === staticStrLast) {
27+
return new Date(helperGetDateTime(getWhatHours(date, 1, staticStrFirst)) - 1)
28+
}
29+
}
30+
return date
31+
}
32+
33+
module.exports = getWhatHours

func/getWhatMinutes.d.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* 返回前几分钟或后几分钟的日期
3+
* @param date 字符串/日期/时间戳
4+
* @param offset 分钟偏移量(默认0)、前几分钟、后几分钟
5+
*/
6+
export declare function getWhatMinutes(date: string | Date | number, offset: number): Date;
7+
8+
/**
9+
* 返回前几分钟或后几分钟的日期
10+
* @param date 字符串/日期/时间戳
11+
* @param offset 分钟偏移量(默认0)、前几分钟、后几分钟
12+
* @param mode 指定秒(null默认当前秒)、0秒(first)、59秒(last)
13+
*/
14+
export declare function getWhatMinutes(date: string | Date | number, offset: number, mode: 'first' | 'last'): Date;
15+
16+
declare module './ctor' {
17+
interface XEUtilsMethods {
18+
getWhatMinutes: typeof getWhatMinutes;
19+
}
20+
}
21+
22+
export default getWhatMinutes

func/getWhatMinutes.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
var staticStrFirst = require('./staticStrFirst')
2+
var staticStrLast = require('./staticStrLast')
3+
var staticParseInt = require('./staticParseInt')
4+
5+
var helperGetDateFullYear = require('./helperGetDateFullYear')
6+
var helperGetDateMonth = require('./helperGetDateMonth')
7+
var helperGetDateTime = require('./helperGetDateTime')
8+
9+
var toStringDate = require('./toStringDate')
10+
var isValidDate = require('./isValidDate')
11+
12+
/**
13+
* 返回前几分钟或后几分钟的日期
14+
*
15+
* @param {Date} date 日期或数字
16+
* @param {Number} offset 分钟偏移量(默认0)、前几分钟、后几分钟
17+
* @param {String} mode 指定秒(null默认当前秒)、0秒(first)、59秒(last)
18+
* @return {Date}
19+
*/
20+
function getWhatMinutes (date, offset, mode) {
21+
date = toStringDate(date)
22+
if (isValidDate(date) && !isNaN(offset)) {
23+
date.setMinutes(date.getMinutes() + staticParseInt(offset))
24+
if (mode === staticStrFirst) {
25+
return new Date(helperGetDateFullYear(date), helperGetDateMonth(date), date.getDate(), date.getHours(), date.getMinutes())
26+
} else if (mode === staticStrLast) {
27+
return new Date(helperGetDateTime(getWhatMinutes(date, 1, staticStrFirst)) - 1)
28+
}
29+
}
30+
return date
31+
}
32+
33+
module.exports = getWhatMinutes

func/getWhatSeconds.d.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* 返回前几秒或后几秒的日期
3+
* @param date 字符串/日期/时间戳
4+
* @param offset 秒偏移量(默认0)、前几秒、后几秒
5+
*/
6+
export declare function getWhatSeconds(date: string | Date | number, offset: number): Date;
7+
8+
/**
9+
* 返回前几秒或后几秒的日期
10+
* @param date 字符串/日期/时间戳
11+
* @param offset 秒偏移量(默认0)、前几秒、后几秒
12+
* @param mode 指定毫秒(null默认当前毫秒)、0毫秒(first)、59毫秒(last)
13+
*/
14+
export declare function getWhatSeconds(date: string | Date | number, offset: number, mode: 'first' | 'last'): Date;
15+
16+
declare module './ctor' {
17+
interface XEUtilsMethods {
18+
getWhatSeconds: typeof getWhatSeconds;
19+
}
20+
}
21+
22+
export default getWhatSeconds

func/getWhatSeconds.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
var staticStrFirst = require('./staticStrFirst')
2+
var staticStrLast = require('./staticStrLast')
3+
var staticParseInt = require('./staticParseInt')
4+
5+
var helperGetDateFullYear = require('./helperGetDateFullYear')
6+
var helperGetDateMonth = require('./helperGetDateMonth')
7+
var helperGetDateTime = require('./helperGetDateTime')
8+
9+
var toStringDate = require('./toStringDate')
10+
var isValidDate = require('./isValidDate')
11+
12+
/**
13+
* 返回前几秒或后几秒的日期
14+
*
15+
* @param {Date} date 日期或数字
16+
* @param {Number} offset 秒偏移量(默认0)、前几秒、后几秒
17+
* @param {String} mode 指定毫秒(null默认当前毫秒)、0毫秒(first)、59毫秒(last)
18+
* @return {Date}
19+
*/
20+
function getWhatSeconds (date, offset, mode) {
21+
date = toStringDate(date)
22+
if (isValidDate(date) && !isNaN(offset)) {
23+
date.setSeconds(date.getSeconds() + staticParseInt(offset))
24+
if (mode === staticStrFirst) {
25+
return new Date(helperGetDateFullYear(date), helperGetDateMonth(date), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds())
26+
} else if (mode === staticStrLast) {
27+
return new Date(helperGetDateTime(getWhatSeconds(date, 1, staticStrFirst)) - 1)
28+
}
29+
}
30+
return date
31+
}
32+
33+
module.exports = getWhatSeconds

0 commit comments

Comments
 (0)