Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
shahradelahi committed Dec 16, 2024
1 parent 2200116 commit e1e035c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 19 deletions.
52 changes: 33 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
# true-ms

![CI](https://github.com/shahradelahi/true-ms/workflows/CI/badge.svg)
![npm bundle size](https://img.shields.io/bundlephobia/min/true-ms)
[![NPM Version](https://img.shields.io/npm/v/true-ms.svg)](https://www.npmjs.com/package/true-ms)
![NPM Bundle Size](https://img.shields.io/bundlephobia/min/true-ms)
![Edge Runtime Compatible](https://img.shields.io/badge/edge--runtime-%E2%9C%94%20compatible-black)

_true-ms_ is a JavaScript package to easily convert various time formats to a precise number of milliseconds by calculating leap years.
_true-ms_ is a JavaScript utility package to easily convert various time formats to a precise number of milliseconds.

---

- [Features](#-features)
- [Installation](#-installation)
- [Examples](#-examples)
- [Convert from Milliseconds](#convert-from-milliseconds)
- [Time Format Written-Out](#time-format-written-out)
- [Convert from Date](#convert-from-date)
- [Convert from Duration Object](#convert-from-duration-object)
- [Convert from a Date](#convert-from-a-date)
- [Convert from Milliseconds](#convert-from-milliseconds)
- [Time Format Written-Out](#time-format-written-out)
- [Documentation](#-documentation)
- [Migrations](#-migrations)
- [Migration from `vercel/ms`](#migration-from-vercelms)
Expand Down Expand Up @@ -54,14 +56,36 @@ ms('-1h') // -3600000
ms('-200') // -200
```

### Convert from Duration Object

<!-- prettier-ignore -->
```js
ms({ hours: 10 }) // 36000000
ms({ days: 2 }) // 172800000
ms({ minutes: 1 }) // 60000
ms({ seconds: 5 }) // 5000
ms({ years: 1 }) // 31536000000
ms({ months: 1, days: 1 }) // 2764800000
```

### Convert from a Date

<!-- prettier-ignore -->
```js
ms('1mon', { from: new Date('2016-01-01') }) // 2678400000 - 31 days in Jan 2016
ms('1mon', { from: new Date('2017-02-01') }) // 2419200000 - 28 days in Feb 2017
ms('1y', { from: new Date('2016-01-01') }) // 31622400000 - Leap year; 366 days
ms('1y', { from: new Date('2015-01-01') }) // 31536000000 - Non-leap year; 365 days
```

### Convert from Milliseconds

<!-- prettier-ignore -->
```js
ms(60000) // "1m"
ms(2 * 60000) // "2m"
ms(-3 * 60000) // "-3m"
ms(ms('10 hours')) // "10h"
ms(60000) // "1m"
ms(2 * 60000) // "2m"
ms(-3 * 60000) // "-3m"
ms(ms('10 hours')) // "10h"
```

### Time Format Written-Out
Expand All @@ -74,16 +98,6 @@ ms(-3 * 60000, { long: true }) // "-3 minutes"
ms(ms('10 hours'), { long: true }) // "10 hours"
```

### Convert from Date

<!-- prettier-ignore -->
```js
ms('1mon', { from: new Date('2016-01-01') }) // 2678400000 - 31 days in Jan 2016
ms('1mon', { from: new Date('2017-02-01') }) // 2419200000 - 28 days in Feb 2017
ms('1y', { from: new Date('2016-01-01') }) // 31622400000 - Leap year; 366 days
ms('1y', { from: new Date('2015-01-01') }) // 31536000000 - Non-leap year; 365 days
```

### 📚 Documentation

For all configuration options, please see [the API docs](https://www.jsdocs.io/package/true-ms).
Expand Down
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
"version": "0.0.0",
"private": false,
"description": "A Millisecond conversion utility with true precision",
"keywords": [
"ms",
"milliseconds",
"conversion",
"time",
"duration",
"utility"
],
"homepage": "https://github.com/shahradelahi/true-ms",
"repository": "github:shahradelahi/true-ms",
"license": "MIT",
Expand Down

0 comments on commit e1e035c

Please sign in to comment.