# time-counting

> You can see how long ago or how long since today.

Latest version **2.0.2** (published 2021-06-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install time-counting
pnpm add time-counting
yarn add time-counting
bun add time-counting
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2021-06-15 |
| First published | 2020-07-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 13.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 17 |
| Author | Sh031224 |
| Maintainers | sh031224 |
| Keywords | time, calculate, time-counting, time counting, calculate time |

## Links

- npm: https://www.npmjs.com/package/time-counting
- Repository: https://github.com/Sh031224/time-counting
- Homepage: https://github.com/Sh031224/time-counting#readme
- Issues: https://github.com/Sh031224/time-counting/issues
- npm.io page: https://npm.io/package/time-counting

## Alternatives

- [@js-joda/timezone](https://npm.io/package/@js-joda/timezone.md) — 383.4K weekly downloads
- [chartjs-adapter-moment](https://npm.io/package/chartjs-adapter-moment.md) — 210.8K weekly downloads
- [strftime](https://npm.io/package/strftime.md) — 171.2K weekly downloads
- [vue-flatpickr-component](https://npm.io/package/vue-flatpickr-component.md) — 115.8K weekly downloads
- [timepicker](https://npm.io/package/timepicker.md) — 51.0K weekly downloads

## Recent versions

- 2.0.2 (latest) — 2021-06-15
- 2.0.1 — 2021-03-11
- 2.0.0 — 2020-12-03
- 1.0.7 — 2020-09-14
- 1.0.6 — 2020-07-31
- 1.0.5 — 2020-07-31
- 1.0.4 — 2020-07-31
- 1.0.3 — 2020-07-30
- 1.0.2 — 2020-07-30
- 1.0.1 — 2020-07-30

## README

# time-counting

[![Travis ci](https://travis-ci.org/Sh031224/time-counting.svg?branch=master)](https://travis-ci.org/github/Sh031224/time-counting)
[![Github issues](https://img.shields.io/github/issues/Sh031224/time-counting)](https://github.com/Sh031224/time-counting/)
[![Githug stars](https://img.shields.io/github/stars/Sh031224/time-counting)](https://github.com/Sh031224/time-counting/)
[![Github license](https://img.shields.io/github/license/Sh031224/time-counting)](https://github.com/Sh031224/time-counting/)
[![Downloads](https://img.shields.io/npm/dy/time-counting)](https://www.npmjs.com/package/time-counting)
[![Npm version](https://img.shields.io/npm/v/time-counting)](https://www.npmjs.com/package/time-counting)
<br/>
📦 A package that lets you know how many days before that date.

[Korean](https://github.com/Sh031224/time-counting/blob/master/README.ko.md)

## Installation

You Can install by npm

```sh
$ npm install time-counting --save
```

or yarn

```sh
$ yarn add time-counting
```

## Usage

### Javascript

```javascript
// es5
const TimeCounting = require("time-counting");
const time = TimeCounting("2020-08-10");
const timecount = TimeCounting("2020-08-10 08:00:00", {
  objectTime: "2020-08-10 10:00:00"
});

//es6
import TimeCounting from "time-counting";
console.log(TimeCounting("2020-08-10"));
console.log(TimeCounting("2020-08-10 08:00:00", { objectTime: "2020-08-10 10:00:00" }));
```

```sh
Output should be how long it is and how much is left from the current time.
2 hours ago
```

### TypeScript

```typescript
import TimeCounting from "time-counting";
console.log(TimeCounting("2020-08-10", { objectTime: "2020-08-11" }));
```

```sh
1 day ago
```

## Options

|    Name    |        Value         |  default   |                 description                 |
| :--------: | :------------------: | :--------: | :-----------------------------------------: |
| objectTime | Date, string, number | new Date() |    It is a standard time for comparison.    |
|    lang    |      "ko", "en"      |    "en"    |                  language                   |
| calculate  |      Calculate       | Calculate  | Choose how far you want the time to appear. |

### Calculate

|  Name   | Value  | default |  Unit  |
| :-----: | :----: | :-----: | :----: |
| justNow | number |   20    | second |
| second  | number |   60    | second |
| minute  | number |   60    | minute |
|  hour   | number |   24    |  hour  |
|   day   | number |    7    |  day   |
|  week   | number |    4    |  week  |
|  month  | number |   12    | month  |

## Example

```javascript
const option = {
  objectTime: "2020-08-10 06:00:00",
  calculate: {
    justNow: 3601
  }
};
console.log(TimeCounting("2020-08-10 05:00:00", option));
```

```sh
just now
```

💬 Up to 1 hour 1 second is displayed as "just now".

## Testing

```sh
npm run test
```

---
_Source: https://npm.io/package/time-counting · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
