0.1.1 • Published 7 years ago

datetime-bling v0.1.1

Weekly downloads
6
License
MIT
Repository
github
Last release
7 years ago

Date-bling

Build Status npm version

An ember-cli addon to display calendar month(s) using moment.js.

Usage

Single month

{{calendar-month
  month=currentMonth
  year=currentYear
  customClassFunction=oneMonthClassFunction}}
currentMonth: null,
currentYear: null,

init() {
  this.set('currentMonth', moment().month());
  this.set('currentYear', moment().year());  
},

oneMonthClassFunction(date) {
  let selectedDays = [1, 2, 3, 5, 8, 13, 21];
    if (selectedDays.includes(date.date()) && moment().isSame(date, 'month')) {
      return 'selected';
    }
},

Multiple months

{{calendar-month-multi
  startDate=today
  endDate=threeMonthsFromNow
  context=(hash
    startDate=today
    endDate=threeMonthsFromNow
  )
  customClassFunction=threeMonthClassFunction}}
today: null,
threeMonthsFromNow: null,

init() {
  this.set('today', moment().startOf('day'));
  this.set('threeMonthsFromNow', moment().startOf('day').add(2, 'months'));
},

threeMonthClassFunction(date) {
  // pass anything you will need anything into this function in 'context'
  const { startDate, endDate } = this.get('context');

  if (date.isSame(startDate, 'day')) {
    return 'start-date';
  }

  if (date.isSame(endDate, 'day')) {
    return 'end-date';
  }

  if (date.isBetween(startDate, endDate)) {
    return 'selected';
  }
}

Installation

In your application's directory: ember install datetime-bling

Contributing

New features and bugfixes are welcome! Feel free to open a pull request.

Running Tests

  • npm test (Runs ember try:each to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Copyright and License

Code and documentation © Copyright 2017 Ryan Rishi. Code released under the MIT License;

0.1.1

7 years ago

0.1.0

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago