GithubHelp home page GithubHelp logo

qyjutils's Introduction

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}

Param Type Description
indexes Array 生日picker组件保存的index值数组。比如:[1,2,3] 农历 3-4

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

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

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

Param Type Description
birthdayStr String 日期字符串,比如:'5-3'
threshold Number 最大差值的阈值,比如传入 7,那么相差7天以上的话就返回-1
isLunar Boolean 日期是公历还是农历,默认公历

qyjUtils.getDateDiff(date1, date2) ⇒ Number

获取两个date差几天。

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

Param Type
date1 Object
date2 Object

qyjUtils.getLunarDate(date) ⇒ String

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

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

Param Type Description
date String 公历日期字符串,比如:'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'

Param Type Description
date Object 结构化日期对象

qyjUtils.toFMD(dateStr) ⇒ Object

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

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

Param Type Description
dateStr String 日期字符串

qyjUtils.addNDay(date, n) ⇒ Object

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

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

Param Type Description
date Object 日期对象
n Number 数字

qyjUtils.substractNDay(date, n) ⇒ Object

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

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

Param Type Description
date Object 日期对象
n Number 数字

qyjUtils.getLunarDay(date) ⇒ String

获取农历是哪天(初几)

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

Param Type Description
date Object 日期对象

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.