1.0.1-beta • Published 4 years ago

bart96-format v1.0.1-beta

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

Node.js – Date format

A node.js package for managing the date format.

Build Status

Installation

$ npm install bart96-format

Usage

const Format = require('bart96-format');

let format = new Format();
format.datetime(); // "2018.06.14 20:08"
format.datetime(1e12); // "2001.09.09 01:46"
format.datetime(1e12, 'Year: yyyy. Day: dd') // "Year: 2001. Day: 09"

let format = new Format({datetimeTpl:'[HH:MM]'});
format.datetime(); // "20:08"
format.datetime(1e12); // "[01:46]"
format.datetime(1e12, 'Year: yyyy. Hours: HH'); // "Year: 2001. Hours: 01"

let format = new Format({durationTpl:'HH hours and MM minutes'});
format.duration(); // "0 hours and 0 minutes"
format.duration(1e7); // "2 hours and 46 minutes"
format.duration(1e7, 'Year: yy, hours: HH'); // "Year: 0. hours: 2"
format.duration(1e7, '{Year: yy,} hours: HH, days: dd'); // "hours: 2, days: 0"
format.duration(1e7, '{Year: yy,} hours: HH, {days: dd}'); // "hours: 2, "

let format = new Format({durationTpl:'HH hours and MM minutes', datetimeTpl:'[HH:MM]'});
format.datetime(1e12); // "[01:46]"
format.duration(1e7); // "2 hours and 46 minutes"

Options (Object)

ParameterTypeOptionalDefaultDescription
UTCbooleanfalseUsing UTC
datetimeTplstringyyyy.mm.dd HH:MMDate format (Mask options)
durationTplstring{ddд} {HHч} MMмDate format (Mask options)

Mask options

MaskDescription (leading zero for one-digit numbers)
yyyyYear represented by four digits.
mmMonth as digits.
ddDay of the month as digits.
HHHours (24-hour clock).
MMMinutes.
SSSeconds.
1.0.0-beta

4 years ago

1.0.1-beta

4 years ago

0.0.2-alpha

6 years ago

0.0.1-alpha

6 years ago

0.0.0-alpha

6 years ago

1.0.0

6 years ago