# moment-calendar

> provides queryable calendar data structure

Latest version **0.0.4** (published 2015-04-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install moment-calendar
pnpm add moment-calendar
yarn add moment-calendar
bun add moment-calendar
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2015-04-23 |
| First published | 2014-11-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Author | Ondrej Brinkel |
| Maintainers | ondrej |
| Keywords | calendar, moment |

## Links

- npm: https://www.npmjs.com/package/moment-calendar
- Repository: git@github.com:der-On/moment-calendar
- Homepage: https://github.com/der-On/moment-calendar
- Issues: https://github.com/der-On/moment-calendar/issues
- npm.io page: https://npm.io/package/moment-calendar

## Dependencies (2)

- [moment](https://npm.io/package/moment.md) ^2.8.3
- [moment-range](https://npm.io/package/moment-range.md) ^1.0.5

## Alternatives

- [@js-joda/timezone](https://npm.io/package/@js-joda/timezone.md) — 383.4K weekly downloads
- [chartjs-adapter-moment](https://npm.io/package/chartjs-adapter-moment.md) — 210.8K weekly downloads
- [strftime](https://npm.io/package/strftime.md) — 171.2K weekly downloads
- [vue-flatpickr-component](https://npm.io/package/vue-flatpickr-component.md) — 115.8K weekly downloads
- [timepicker](https://npm.io/package/timepicker.md) — 51.0K weekly downloads

## Recent versions

- 0.0.4 (latest) — 2015-04-23
- 0.0.3 — 2014-11-03
- 0.0.2 — 2014-11-03

## README

# Moment Calendar

Provides queryable calendar data structure.

Based on [moment.js](http://momentjs.com).

## Install

```bash
$ npm install moment-calendar
```

## Usage

```javascript
var Calendar = require('moment-calendar');

var calendar = new Calendar({
  // name of the property in event objects containing the start date
  eventStartDate: 'start',
  // name of the property in event objects containing the end date
  eventEndDate: 'end',
  // locale
  locale: 'en'
});

// you can reconfigure an existing calendar
calendar.configure({
  eventStartDate: 'from',
  eventEndDate: 'to',
  locale: 'de'
});

var event = {
  start: new Date(), // begins now
  end: (new Date()).getTime() + (1000 * 60 * 60 * 24) // ends in one day
};

// calendar is an array like object
calendar.push(event);

// returns new calendar containing events within the year 2014
var eventsIn2014 = calendar.findInYear(2014);

// events are always sorted by theire start date

// by chaining you can get as granular as you need
var events = calendar.findInYear(2014).findInMonth(5).findInDate(20);

// you can also query ranges, a new calendar is returned
var eventsInRange = calendar.findInRange('2013-01-01', '2013-12-31');

// returns a list of months, the list items are calendar instances too
var months = calendar.months(2014);

months.forEach(function(month, i) {
  // list of weeks within the month
  var weeks = month.weeks();
  
  weeks.forEach(function(week, i) {
    // list of days within the month
    var days = week.days();
    
    days.forEach(function(day, i) {
      // list of hours within the day
      var hours = day.hours();
      
      hours.forEach(function(hour, i) {
        // list of events within the hour
        var events = day.events();
      });    	
    });
  });
});
```

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