Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

nuke-biz-moment

nuke-biz170.0.6

精简版本、适用于 weex 应用的 moment 库,用于日期处理,提供日期解析、格式化等方便的工具类。

nuke, nue-biz, moment, rax

readme

nuke-biz-moment

  • category: biz-util
  • chinese: 时间处理
  • type: 工具组件

何时使用

精简版本、适用于 weex 应用的 moment 库,用于日期处理,提供日期解析、格式化等方便的工具类。

// 该组件不在 nuke 大包中,需要单独安装依赖
// 切换到你的项目中
npm install nuke-biz-moment --save

// 打开工程文件
import moment from 'nuke-biz-moment';

console.log(moment().format('YYYY/MM/DD'))

API

格式化类

// 按照指定格式格式化
moment('2017/5/22').format('YYYY/MM/DD hh:mm:ss')  // 2017/08/17 13:52:43
`

获取类

moment('2017/5/22').year() 
moment('2017/5/22').month() 
moment('2017/5/22').date() 
moment('2017/5/22').second()
moment('2017/5/22').minute()
moment('2017/5/22').format()

检验类

moment('2017/35/22').isValid() // false
moment('2017/10/20').isAfter('2017/10/19'); // true

计算类

// 减几天
moment('2017/07/22').addDay(-2).format('YYYY/MM/DD')} // 2017-07-20

// 月份有多少天
moment("2012/02", "YYYY/MM").daysInMonth() //29

注意

由于ios jscore的原因,在ios上使用该组件尤其是format方法,需将类似 2017-08-30 时间格式首先格式化为 2017/08/30 ,否则无法渲染。

changelog

Changelog

0.0.6 / 2018-03-06

  • [eb03190] - feat update package to expose src folder

0.0.5 / 2017-08-31

0.0.4 / 2017-08-17

0.0.3 / 2017-08-17

  • [47898e2] - fix update package.json
  • [cc3bf20] - fix 更新文档,美化 demo

0.0.2 / 2017-07-20

0.0.1 / 2017-07-20