1.4.2 • Published 6 years ago

datepickr v1.4.2

Weekly downloads
17
License
ISC
Repository
github
Last release
6 years ago

Datepickr

The do it yourself date picker. It makes as no assumptions how it's shown on the page. See demo.

  • Need to show/hide it on an input field? Do it yourself.
  • Need to have it insert one date after selection? Do it yourself.
  • Need nice formatted dates after selection? Do it yourself.

Usage

<div id='datepickr'></div>

<script>
    var el = document.getElementById('datepickr');
    new Datepickr(el, function(res) {
       // console.log(res);
    });
</script>

API

new Datepickr(element, callback, options);

The callback returns an array of arrayed dates whenever a date is selected.

[
    [1412481600000,1],
    [1413864000000,1],
    [1413950400000,1],
    [1414468800000,1]
]

The first field value is a timestamp along with 1 or 0.5 depending on whether halfdays are enabled as an option or not.

OptionDefault ValueDescription
weekdaysAn array of weekday strings in EnglishOption for translation
monthsAn array of month strings in EnglishOption for translation
startYearCurrent yearStart the date picker on a particular year
startMonthCurrent monthStart the date picker on a particular month
minDatenulla timestamp representing a maximum date the pager should page
maxDatenulla timestamp representing a minimum date the pager should page
halfDayfalseEnables halfday selection of dates
omitPastfalsePrevent selecting days in the past
omitFuturefalsePrevent selecting days in the future
omitWeekendsfalsePrevent selecting weekends
omitDaysEmpty arrayPass a timestamp array of dates to prevent the selection of
activeDaysEmpty arrayPass an array of arrayed dates ie. [[[1413950400000,1],[1414468800000,0.5] that are auto selected on load
utcfalseShould date output be interpreted as UTC
singleSelectionfalseLimit days selection to one day.

To see examples of each option see the demos.

Adding/Removing options after initialization.

var pickr = new Datepickr(el);
pickr.options({
    halfDay: true
});

Use with node or browserify.

// npm install datepickr
var datepickr = require('datepickr')

datepickr(el, function(res) {
  console.log(res);
});

Developing

npm install && npm start

Building

npm run build

Credits

Code originally based off of datepickr.

1.4.2

6 years ago

1.4.1

8 years ago

1.4.0

8 years ago

1.3.0

9 years ago

1.2.0

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago