1.1.2 • Published 7 years ago

bella-date v1.1.2

Weekly downloads
24
License
MIT
Repository
github
Last release
7 years ago

bella-date

Simple util for datetime manipulation in your Node.js and browser apps.

NPM Build Status codecov Dependency Status NSP Status

Setup

Usage

import {
  format,
  relativize,
  local,
  utc
} from 'bella-date';

let t = 1479374694886;

format(t, 'Y/m/d h:i:s'); //=> 2016/02/18 15:28:20
local(t); //=> Thu, 17 Nov 2016 16:24:54 GMT+0007
utc(t); //=> Thu, 17 Nov 2016 09:24:54 GMT
relativize(t); //=> 2 minutes ago

APIs

Default pattern for .format() method is 'D, M d, Y H:i:s A'.

Here are the available characters:

  • Y: full year, ex: 2050
  • y: short year, ex: 50
  • F: full month name, ex: August
  • M: short month name, ex: Aug
  • m: month index with zero, ex: 08 (in 08/24/2050)
  • n: short month name with no zero, ex: 8 (in 8/24/2050)
  • S: the ordering subfix for date, ext: 1st, 2nd, 3rd, 4th
  • j: day of the month, with no zero, ex: 3 (in 18/3/2050)
  • d: day of the month, with zero, ex: 03 (in 18/03/2050)
  • t: date in year
  • w: weekday in number
  • l: long name of weekday, ex: Sunday
  • D: short name of weekday, ex: Sun
  • G: hour, with no zero: 0 - 24
  • g: hour, with no zero: 0 - 12
  • h: hour, with zero: 00 - 24
  • i: minute: 00 - 59
  • s: second: 00 - 59
  • a: am, pm
  • A: AM, PM
  • O: timezone

Test

git clone https://github.com/ndaidong/bella-date.git
cd bella-date
npm install
npm test

License

The MIT License (MIT)

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago