Some utility functions for cloud function develeopment of Tencent miniprogram. 给小程序云函数公用的一些工具方法
-
qyjUtils
-
.getDateByIndex(indexes) ⇒
Object
-
.getBirthdayDiff(birthdayStr, threshold, isLunar) ⇒
Number
-
.getDateDiff(date1, date2) ⇒
Number
-
.getLunarDate(date) ⇒
String
-
.todayFMD() ⇒
Object
-
.toDateStr(date) ⇒
String
-
.toFMD(dateStr) ⇒
Object
-
.addNDay(date, n) ⇒
Object
-
.substractNDay(date, n) ⇒
Object
-
.getLunarDay(date) ⇒
String
-
.getDateByIndex(indexes) ⇒
根据小程序生日picker组件生成的index,返回实际的日期
Kind: static method of qyjUtils
Returns: Object
- {isLunar, date}
Param | Type | Description |
---|---|---|
indexes | Array |
生日picker组件保存的index值数组。比如:[1,2,3] 农历 3-4 |
获取离生日 date 相差几天,支持农历。返回值为整数。
Kind: static method of qyjUtils
Returns: Number
- 生日未过且离${threshold}天以内返回原值,否则返回-1
Param | Type | Description |
---|---|---|
birthdayStr | String |
日期字符串,比如:'5-3' |
threshold | Number |
最大差值的阈值,比如传入 7,那么相差7天以上的话就返回-1 |
isLunar | Boolean |
日期是公历还是农历,默认公历 |
获取两个date差几天。
Kind: static method of qyjUtils
Returns: Number
- 默认排序规则,date1小,date2大,返回正数。反之返回负数。
Param | Type |
---|---|
date1 | Object |
date2 | Object |
获取某一天的农历日期。返回值为日期字符串
Kind: static method of qyjUtils
Returns: String
- 农历日期字符串
Param | Type | Description |
---|---|---|
date | String |
公历日期字符串,比如:'2022-5-3' |
获取当日的结构化对象
Kind: static method of qyjUtils
Returns: Object
- {year, month, day}
获取日期字符串
Kind: static method of qyjUtils
Returns: String
- 日期字符串,比如:'2022-5-20'
Param | Type | Description |
---|---|---|
date | Object |
结构化日期对象 |
返回日期字符串对应的结构化对象
Kind: static method of qyjUtils
Returns: Object
- {year, month, day}
Param | Type | Description |
---|---|---|
dateStr | String |
日期字符串 |
获取某日的后n天日期对象:按时间戳计算偏移,再反解析为日期
Kind: static method of qyjUtils
Returns: Object
- 日期对象
Param | Type | Description |
---|---|---|
date | Object |
日期对象 |
n | Number |
数字 |
获取某日的前n天日期对象:按时间戳计算偏移,再反解析为日期
Kind: static method of qyjUtils
Returns: Object
- 日期对象
Param | Type | Description |
---|---|---|
date | Object |
日期对象 |
n | Number |
数字 |
获取农历是哪天(初几)
Kind: static method of qyjUtils
Returns: String
- 农历日子。比如:'初三'
Param | Type | Description |
---|---|---|
date | Object |
日期对象 |