0.1.1 • Published 3 years ago

just-dates v0.1.1

Weekly downloads
11
License
MIT
Repository
github
Last release
3 years ago

Just Dates 🗓

codecov

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

API inspired by date-fns

Installation

NPM

npm i --save just-dates

Yarn

yarn add just-dates

Usage

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
0.1.0

3 years ago

0.1.1

3 years ago

0.0.22

4 years ago

0.0.21

4 years ago

0.0.20

4 years ago

0.0.19

4 years ago

0.0.17

4 years ago

0.0.18

4 years ago

0.0.16

4 years ago

0.0.15

4 years ago

0.0.14

4 years ago

0.0.10

4 years ago

0.0.11

4 years ago

0.0.12

4 years ago

0.0.13

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.3

4 years ago

0.0.4

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago