4.1.0 • Published 6 years ago

date-arithmetic v4.1.0

Weekly downloads
178,713
License
MIT
Repository
github
Last release
6 years ago

Date Arthmetic

A simple object containing some date math utils in the spirit of Moment.js. Unlike Moment this module, returns real date objects, so it isn't chainable.

import * as dateMath from 'date-arithmetic'

var date = dateMath.month(new Date)

API

all api methods return a new date. Date objects are never mutated.

Accessors

get and set date part values.

  • dateMath.milliseconds(date, [value])
  • dateMath.seconds(date, [value])
  • dateMath.minutes(date, [value])
  • dateMath.hours(date, [value])
  • dateMath.date(date, [value])
  • dateMath.day(date, [value])
  • dateMath.weekday(date, [value], [firstOfWeek = 0])
  • dateMath.month(date, [value])
  • dateMath.year(date, [value])
  • dateMath.decade(date, [value])
  • dateMath.century(date, [value])

startOf(data, unit, [firstOfWeek = 0])

return a new date with the relevent date parts zero'd out. You only need to provide a firstOfWeek when the unit is 'week'

dateMath.startOf(new Date, 'day') // -> no time components

Valid unit values are; "seconds", "minutes", "hours", "day", "week", "month", "year", "decade", "century"

endOf(data, unit)

the opposite of startOf

dateMath.endOf(new Date, 'day') // -> one millisecond before tomorrow

Valid unit values are; "milliseconds", "seconds", "minutes", "hours", "day", "weekday", "month", "year", "decade", "century".

Math Functions

Arithmetic functions

  • dateMath.add(date, value, unit)
  • dateMath.subtract(date, value, unit)
  • dateMath.eq(dateA, dateB, [unit])
  • dateMath.neq(dateA, dateB, [unit])
  • dateMath.gte(dateA, dateB, [unit])
  • dateMath.gt(dateA, dateB, [unit])
  • dateMath.lte(dateA, dateB, [unit])
  • dateMath.lt(dateA, dateB, [unit])
  • dateMath.inRange(day, min, max, unit)
  • dateMath.min(dateA, dateB, dateN)
  • dateMath.max(dateA, dateB, dateN)
  • dateMath.diff(dateA, dateB, unit, asFloat)

Valid unit values are; "seconds", "minutes", "hours", "day", "week", "month", "year", "decade", "century"

carbonio-calendars-ui@fadi-saadeldin/react-big-calenderinstant-bookergribovsky-react-big-calendarreact-widgetsfork@everything-registry/sub-chunk-1447tamavo-calendartangocode-react-big-calendarwink-react-big-calendarstanza-big-calendarstanza-calendar-interfaceux-schedule-mobileivelum-react-widgetsitz-big-calendarirx-react-big-calendarkandooit_calendarkandooit_schedulerjhockett-react-big-calendarjg-react-big-calendarjnarwold-react-big-calendariqatestappjalali-react-big-calendarjalali-react-calendarkatoto-big-calendarjvenusaur-react-big-calendarkyon-react-big-calendaric-react-big-calendarhw-calendarhomex-react-big-calendargreets-big-calendargreets-react-big-calendarguyanbiao-calenderleyserplus-react-big-calendarliu-big-calendarmana-calendarmana-calendar-v2m-ceshi-calendar@xetoxyc/react-big-calendar@truehome/react-big-calendar@tibordunai/react-big-calendar@theoremone/th1-calendar@trialspark/react-big-calendar@vietmoney/react-big-calendar@veupathdb/componentsauchindoun-react-big-calendarappdoc-component@chroniq/chroniq@chroniq/chroniq-storybook@clickonmedia/clickon-react-big-calendar@clickonmedia/react-big-calendar@cicobuff/react-big-calendar@cm-iv/react-bigger-calendar@eduardomrodrigues/react-big-calendar-pt-br@connerl/react-big-calendar@craigmorton/react-big-calendarstockwell-calendarsp-react-big-calendarubiatar-react-big-calendarumd-jira-toolsticlo-big-calendartrello-cal@checksub_team/react-widgets@cdb/calendarwebdoods-react-big-calendar@lacework/react-widgets-fork@longsleep/react-big-calendar@nhuthuynh/react-big-calendarmy-own-fs-big-calendarmy-test-calendarmetaboly-react-big-calendaroptune-react-big-calendarsc-react-big-calendarscheduler_kandooitrbc-iframerbc-with-a11yrbc-fork-react-big-calendarreact-calendar-eventsreact-big-calendar-modified-enjreact-big-calendar-modifyreact-big-calendar-momentreact-big-calendar-multiday-dragreact-big-calendar-multiselectreact-big-calendar-mwreact-big-calendar-mycasereact-big-calendar-nextreact-big-calendar-nowreact-big-calendar-optreact-big-calendar-preact-big-calendar-rocketsourcereact-big-calendar-schedulerreact-big-calendar-shamsireact-big-calendar-shrinkedreact-big-calendar-slotreact-big-calendar-sweetreact-big-calendar-teaboughreact-big-calendar-temporaryreact-big-calendar-testreact-big-calendar-touchreact-big-calendar-unavailablereact-big-calendar-upgrade
4.1.0

6 years ago

4.0.1

6 years ago

4.0.0

6 years ago

3.1.0

9 years ago

3.0.1

10 years ago

3.0.0

11 years ago

2.0.0

11 years ago

1.0.0

11 years ago