# just-dates

> parse/manipulate/format/query/compare objects as dates

Latest version **0.1.1** (published 2021-07-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install just-dates
pnpm add just-dates
yarn add just-dates
bun add just-dates
```

## Health

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

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

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2021-07-11 |
| First published | 2020-08-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 191.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Luke Pearson |
| Maintainers | luke.pearson |
| Keywords | date, compare, query, validate, parse, format, objects |

## Links

- npm: https://www.npmjs.com/package/just-dates
- Repository: https://github.com/lukepearson/just-dates
- Homepage: https://github.com/lukepearson/just-dates#readme
- Issues: https://github.com/lukepearson/just-dates/issues
- npm.io page: https://npm.io/package/just-dates

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2021-07-11
- 0.1.0 — 2021-07-11
- 0.0.22 — 2020-11-07
- 0.0.21 — 2020-11-07
- 0.0.20 — 2020-11-07
- 0.0.19 — 2020-09-27
- 0.0.18 — 2020-09-26
- 0.0.17 — 2020-09-25
- 0.0.16 — 2020-09-20
- 0.0.15 — 2020-09-20
- 0.0.14 — 2020-09-15
- 0.0.13 — 2020-09-13
- 0.0.12 — 2020-09-13
- 0.0.11 — 2020-09-13
- 0.0.10 — 2020-09-13
- … 9 more at https://npm.io/package/just-dates/versions

## README

# Just Dates 🗓

[![codecov](https://codecov.io/gh/lukepearson/just-dates/branch/master/graph/badge.svg)](https://codecov.io/gh/lukepearson/just-dates)


Parse / modify / query / format / compare dates as plain objects without converting them to datetimes.

API inspired by [date-fns](https://date-fns.org/)

## Installation

NPM
```bash
npm i --save just-dates
```
Yarn
```bash
yarn add just-dates
```

## Usage

```js
import { 
  DateObject, addDays, format, localToday, addYears, addMonths, getStartOfWeekYear 
} from 'just-dates';

const today: DateObject = localToday();
const in20Days = addDays(today, 20);
const in20Months = addMonths(today, 20);
const in20Years = addYears(today, 20);

console.log(`20 days from now is ${format(in20Days)}`);
console.log(`20 months from now is ${format(in20Months)}`);
console.log(`20 years from now is ${format(in20Years)}`);
console.log(`The start of the calendar year is ${getStartOfWeekYear(today)}`);
```

## API
### Modifiers (returns new DateObject)
* add
* addDays
* addMonths
* addQuarters
* addWeekDays
* addWeeks
* addYears
* set
* setDay
* setDayOfYear
* setDayOfWeek
* setMonth
* setQuarter
* setWeek
* setYear
* sub
* subDays
* subMonths
* subQuarters
* subWeekDays
* subWeeks
* subYears

### Durations
* getDuration
* formatDuration

### Comparators
* diffDays
* diffMonths
* diffQuarters
* diffWeekDays
* diffWeeks
* diffYears

### Generators
* localToday
* UTCToday
* generateMonth
* generateRange
* generateWeek
* generateYear
* generateWeekYear

### Formatters
* format
* formatDistance
* formatFromNow

### Queries
* getDayOfYear
* getDaysInMonth
* getDaysInYear
* getEndOfMonth
* getEndOfQuarter
* getEndOfWeek
* getEndOfWeekYear
* getEndOfYear
* getQuarter
* getStartOfDecade
* getStartOfMonth
* getStartOfQuarter
* getStartOfWeek
* getStartOfWeekYear
* getStartOfYear
* getCalendarWeek
* getCalendarWeeksInYear
* getCalendarYear
* getTotalDays
* getWeekOfMonth
* getWeeksInMonth
* isAfter
* isBefore
* isEqual
* isFriday
* isLastDayOfMonth
* isLeapYear
* isMonday
* isNumberLeapYear
* isSameMonth
* isSameQuarter
* isSameWeek
* isSameYear
* isSaturday
* isSunday
* isThursday
* isTuesday
* isValid
* isWednesday
* isWeekend
* max
* min

### Parsers
* parseString
* parseDate

## Terms
* day - day of the month (1-31)
* month - month of the year (1-12)
* year - year number (1-????)
* weekYear - ISO week-numbering year 
* week - ISO week number (1-53)
* weekDay - day of the week (1-7, starting on Monday)

## Todo
* Locales
* Allow changing first day of week

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