1.0.6 • Published 2 years ago

qyjutils v1.0.6

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

qyjUtils

Some utility functions for cloud function develeopment of Tencent miniprogram. 给小程序云函数公用的一些工具方法

qyjUtils.getDateByIndex(indexes) ⇒ Object

根据小程序生日picker组件生成的index,返回实际的日期

Kind: static method of qyjUtils
Returns: Object - {isLunar, date}

ParamTypeDescription
indexesArray生日picker组件保存的index值数组。比如:1,2,3 农历 3-4

qyjUtils.getBirthdayDiff(birthdayStr, threshold, isLunar) ⇒ Number

获取离生日 date 相差几天,支持农历。返回值为整数。

Kind: static method of qyjUtils
Returns: Number - 生日未过且离${threshold}天以内返回原值,否则返回-1

ParamTypeDescription
birthdayStrString日期字符串,比如:'5-3'
thresholdNumber最大差值的阈值,比如传入 7,那么相差7天以上的话就返回-1
isLunarBoolean日期是公历还是农历,默认公历

qyjUtils.getDateDiff(date1, date2) ⇒ Number

获取两个date差几天。

Kind: static method of qyjUtils
Returns: Number - 默认排序规则,date1小,date2大,返回正数。反之返回负数。

ParamType
date1Object
date2Object

qyjUtils.getLunarDate(date) ⇒ String

获取某一天的农历日期。返回值为日期字符串

Kind: static method of qyjUtils
Returns: String - 农历日期字符串

ParamTypeDescription
dateString公历日期字符串,比如:'2022-5-3'

qyjUtils.todayFMD() ⇒ Object

获取当日的结构化对象

Kind: static method of qyjUtils
Returns: Object - {year, month, day}

qyjUtils.toDateStr(date) ⇒ String

获取日期字符串

Kind: static method of qyjUtils
Returns: String - 日期字符串,比如:'2022-5-20'

ParamTypeDescription
dateObject结构化日期对象

qyjUtils.toFMD(dateStr) ⇒ Object

返回日期字符串对应的结构化对象

Kind: static method of qyjUtils
Returns: Object - {year, month, day}

ParamTypeDescription
dateStrString日期字符串

qyjUtils.addNDay(date, n) ⇒ Object

获取某日的后n天日期对象:按时间戳计算偏移,再反解析为日期

Kind: static method of qyjUtils
Returns: Object - 日期对象

ParamTypeDescription
dateObject日期对象
nNumber数字

qyjUtils.substractNDay(date, n) ⇒ Object

获取某日的前n天日期对象:按时间戳计算偏移,再反解析为日期

Kind: static method of qyjUtils
Returns: Object - 日期对象

ParamTypeDescription
dateObject日期对象
nNumber数字

qyjUtils.getLunarDay(date) ⇒ String

获取农历是哪天(初几)

Kind: static method of qyjUtils
Returns: String - 农历日子。比如:'初三'

ParamTypeDescription
dateObject日期对象
1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago