@deepjs/date

0.2.9 • Public • Published

date

日期相关格式处理

独立包,无依赖

功能列表

  • formatNum
  • formatDate
  • formatCountDown => genCountdownStr
  • genCountdownObj
  • genSplitorObj

使用

import {
  formatNum,
  formatDate,
  formatCountDown, // 计划废弃,请使用 genCountdownStr 替代
  genCountdownStr,
  genCountdownObj,
  genSplitorObj,
} from '@deepjs/date'

const format = 'd天H:F:S'

formatNum(0) // 00
formatCountDown(10000) // '00:00:10'

// 新方法
genCountdownStr(9000) // '00:00:09'
genCountdownObj(9000)
// { d: 0, H: '00', h: 0, F: '00', f: 0, S: '09', s: 9 }
genSplitorObj(format)
// { H: ':', F: ':', S: ''}
genSplitorObj('d天 H时f分S秒')
// {d: '天 ', H: '时', f: '分', S: '秒'}


const date = +new Date('2018-12-17 19:04:09');
formatDate(date)                  // '2018年12月17日'
formatDate(date, 'M-D')           // '12-17'
formatDate(date, 'Y-M-D H:F:S')   // '2018-12-17 19:04:09'

Readme

Keywords

Package Sidebar

Install

npm i @deepjs/date

Weekly Downloads

0

Version

0.2.9

License

MIT

Unpacked Size

8.57 kB

Total Files

3

Last publish

Collaborators

  • cloudyan