# count-to-day

> A simple javascript package that calculates countdown to a particular day of the week

Latest version **1.0.9** (published 2023-12-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install count-to-day
pnpm add count-to-day
yarn add count-to-day
bun add count-to-day
```

## 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 | 1.0.9 |
| Published | 2023-12-28 |
| First published | 2023-10-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Taofeeq Oluderu |
| Maintainers | taofeeq-deru |
| Keywords | countdown, countdown-timer, count-to-day, countdown-to-day, date, day-counter, javascript, react, vue, angular, next |

## Links

- npm: https://www.npmjs.com/package/count-to-day
- Repository: https://github.com/Taofeeq-deru/count-to-day
- Homepage: https://github.com/Taofeeq-deru/count-to-day#readme
- Issues: https://github.com/Taofeeq-deru/count-to-day/issues
- npm.io page: https://npm.io/package/count-to-day

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.9 (latest) — 2023-12-28
- 1.0.8 — 2023-12-28
- 1.0.7 — 2023-12-25
- 1.0.6 — 2023-10-26
- 1.0.5 — 2023-10-25
- 1.0.4 — 2023-10-25
- 1.0.3 — 2023-10-25
- 1.0.2 — 2023-10-25
- 1.0.1 — 2023-10-25
- 1.0.0 — 2023-10-25

## README

# count-to-day

It is a lightweight javascript package that calculates countdown to a particular day of the week.

## Installation

```js
npm install count-to-day --save
//or with yarn
yarn add count-to-day
```

## Params

| Params        | Type                                                                                     | Description                                                                                                                                  |
| ------------- | ---------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| dayOfWeek     | 'sunday' \| 'monday' \| 'tuesday' \| 'wednesday' \| 'thursday' \| 'friday' \| 'saturday' | the day of the week you want to count down to                                                                                                |
| countDownCb   | function                                                                                 | call back function whose params contains the countdown object: _{days: number, hours: number, minutes: number, seconds: number }_            |
| timeToCountTo | string                                                                                   | not mandatory. The time to count to, uses 24 hours clock time, e.g '12:00:00', '16:00:00', '1:00:00'. Defaults to _'00:00:00'_ (12 midnight) |
| isInfinite    | boolean                                                                                  | A boolean flag that determines if the time should restart after the date to countdown to is reached. Defaults to _false_                     |

## Usage

```js
import { CountDownToDay } from "count-to-day";

CountDownToDay("wednesday", (count) => console.log("count=", count), "10:42:00");
//=> count =  { days: number, hours: number, minutes: number, seconds: number }
//(logs an object like this that contains the countdown)
```

Or use in a custom hook

```js
import { useEffect, useState } from "react";
import { CountDownToDay, StopCountdown } from "count-to-day";

const useCountdown = (dayOfWeek = "friday", timeToCountTo = "00:00:00") => {
  const [count, setCount] = useState({
    days: "",
    hours: "",
    minutes: "",
    seconds: ""
  });

  useEffect(() => {
    CountDownToDay(dayOfWeek, setCount, timeToCountTo);

    return () => {
      StopCountdown();
    };
  }, [dayOfWeek, timeToCountTo]);

  return { count };
};

export default useCountdown;
```

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