4.1.0 • Published 5 years ago

date-arithmetic v4.1.0

Weekly downloads
178,713
License
MIT
Repository
github
Last release
5 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-mobile@billchenchina/react-big-calendar@cm-iv/react-bigger-calendar@craigmorton/react-big-calendar@connerl/react-big-calendar@brainwayltd/react-big-calendarivelum-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-calendarstockwell-calendarsp-react-big-calendarubiatar-react-big-calendarumd-jira-toolsticlo-big-calendartrello-cal@atenaganji/arsh-react-big-calendar@atenaganji/react-big-calendar@atenaganji/react-big-calendar-arsh@aerotime/react-big-calendar@ahaui/full-calendar@alex_lai/gg-react-big-calendar@b.taranenko/react-big-calendar@beisen-platform/calendar@beisen/calendar@beisen/pps-calendar@beisen/m-calendar@beisen/m-m-calendar@checksub_team/react-widgets@cdb/calendar@chroniq/chroniq@chroniq/chroniq-storybook@cicobuff/react-big-calendar@clickonmedia/clickon-react-big-calendar@clickonmedia/react-big-calendar@4c/todos-api192.168.0.172@davidmh/react-big-calendar@denindka/react-big-calendar@danielmackenzie8/react-widgetswebdoods-react-big-calendar@filebroker/react-widgets@fibery/react-big-calendar@fedotxxl/react-big-calendar@fellow/react-big-calendar@healthadvisor/react-big-calendar@headway/react-big-calendar@holidaycheck/liam-tasks@hitask/react-big-calendar@eduardomrodrigues/react-big-calendar-pt-br@emilio.rc/rapid-circle-big-calendar@elationhealth/react-big-calendar@getinsitu/react-big-calendar@kopano/react-big-calendar@kraftman/react-big-calendar@lacework/react-widgets-fork@longsleep/react-big-calendar@mashirow/react-big-calendar@nhuthuynh/react-big-calendar@nlevchuk/react-big-calendar@noloco/react-big-calendar@epsilon-cloud/react-big-calendar@erichahn/react-big-calendar@fadi-saadeldin/react-events-calender@mikailbayram/react-big-calendar@mikailbayram/serviceroller-calendar@mercuriya/react-big-calendar@mirror/react-big-calendar@mondaydotcomorg/react-big-calendar@jvenusaur/react-big-calendar@kemoke/react-big-calendar@jatsri/js-html-css-playground@kolkovsky/react-big-calendar@kirofy.com/isomorphic-core@kirofy.com/isomorphic-package@jeremymauzy/react-big-calendar@olegwock/react-big-calendar@omnicodesolutions/react-big-calendar@react-next-calendar/utils
4.1.0

5 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

10 years ago

2.0.0

10 years ago

1.0.0

11 years ago