0.0.6 • Published 6 years ago

nuke-biz-moment v0.0.6

Weekly downloads
30
License
-
Repository
gitlab
Last release
6 years ago

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 ,否则无法渲染。

0.0.6

6 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago