New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

just-dates

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

just-dates

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

0.1.1
latest
Source
npm
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

date

FAQs

Package last updated on 11 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts