1.1.0 • Published 2 years ago

ms-time-tools v1.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

About

ms-time-tools is a powerful Node.js module that allows you to easily manage time.

Features

Installation

npm install --save ms-time-tools

Examples

const  mtt = require('ms-times-tools'); // Import the module

Convert from milliseconds

Here is the list of all the arguments available: |Parameter|Type|Optional|Default|Description| |:-:|:-:|:-:|:-:|:-:| |time|number|❌||Time in milliseconds to convert into string| |format|string|✅|Y-MO-W-D-H-M-S-MS|Format and order of time returned| |lang|string|✅|en|Language of time unities| |long|boolean|✅|false|Returns the whole word (not abbreviations)| |separator|string|✅|, |Separators of time values| |suppressTag|boolean|✅|false|Returns time without unities| |valueNull|boolean|✅|false|Removes values equal to zero|

Some usage examples:

mtt.stringifyTime(61000); // 1m, 1s

mtt.stringifyTime(
    617780000,
	{
	    format: 'Y-MO-W-D-H-M-S-MS',
		lang: 'en',
		long: true
	}
); // 1 week, 3 hours, 36 minutes, 20 seconds

mtt.stringifyTime(
	5100300,
	{
		valueNull: true,
		separator: '/'
	}
); // 0y/0mo/0w/0d/1h/25m/0s/3ms

mtt.stringifyTime(
	35071,
	{ suppressTag: true }
); // 35, 71

Convert from string

Here is the list of all the arguments available: |Parameter|Type|Optional|Default|Description| |:-:|:-:|:-:|:-:|:-:| |time|string|❌||Time in string to convert into milliseconds| |msOff|boolean|✅|false|Returns time in seconds instead of milliseconds|

Some usage examples:

mtt.parseTime('1 minute 1 second'); // 61000

mtt.parseTime(
    '2h 5m',
	{ msOff: true }
); // 7500

mtt.parseTime('1 month 2d 4hours'); // 187260000

mtt.stringifyTime(
	35071,
	{ suppressTag: true }
); // 35, 71

Format time

Here is the list of all the arguments available: |Parameter|Type|Optional|Default|Description| |:-:|:-:|:-:|:-:|:-:| |time|string|❌||Time to format| |format|string|✅|y YYYY, mo MMMM, d DD H:M:S.MS|Format and order of time returned, check here for more information| |lang|string|✅|en|Language of time unities| |long|boolean|✅|false|Returns the whole word (not abbreviations)| |suppressTag|boolean|✅|false|Returns time without unities| |valueNull|boolean|✅|false|Removes values equal to zero|

Some usage examples:

mtt.formatTime(654686145655); // 20 years, 8 months, 29 days 01:00:25.655

mtt.formatTime(
    65364,
    { format: 'M:S.MS' }
); // 01:05.364

mtt.formatTime(
    449155098,
    { format: 'D DD, h:M:S.ms' }
); // 05 days, 4:45:55.98
1.1.0

2 years ago

1.0.99992

2 years ago

1.0.99991

2 years ago

1.0.9999

2 years ago

1.0.999

2 years ago

1.0.998

2 years ago

1.0.997

2 years ago

1.0.996

2 years ago

1.0.995

2 years ago

1.0.994

2 years ago

1.0.993

2 years ago

1.0.992

2 years ago

1.0.991

2 years ago

1.0.990

2 years ago

1.0.989

2 years ago

1.0.988

2 years ago

1.0.97

2 years ago

1.0.96

2 years ago

1.0.9585

2 years ago

1.0.9584

2 years ago

1.0.9583

2 years ago

1.0.9582

2 years ago

1.0.9581

2 years ago

1.0.958

2 years ago

1.0.957

2 years ago

1.0.956

2 years ago

1.0.955

2 years ago

1.0.954

2 years ago

1.0.953

2 years ago

1.0.952

2 years ago

1.0.951

2 years ago

1.0.95

2 years ago

1.0.94

2 years ago

1.0.932

2 years ago

1.0.931

2 years ago

1.0.93

2 years ago

1.0.92

2 years ago

1.0.91

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago