npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

date-range-picker

v0.3.5

Published

a simple daterangepicker

Downloads

1,338

Readme

daterangepicker

NPM version Downloads

build Build Status Coverage Status

a simple daterangepicker

DEMO

Click here

What achieved

  1. calendar component base on moment.js
  2. date simple picker
  3. date range picker
  4. date terminal picker

compatibility for IE

  • Because of using browserify, if you don't need hour and minute picker, it supports IE9.
  • If you need hour and minute picker, because of using range input, it supports IE10.

Usage

This component relies on moment and moment-range, so you should include them first

  $ npm install date-range-picker
  $ bower install date-range-picker // or use bower

Include js in /dist by tag , you can also require js by require('date-range-picker')

  var configs1 = {
    lang: 'zh-cn', // using language
    numberOfCalendars: 1, // displaying month number
    calendarType: 'day', // type of calendar, day, week or month, dafault 'day'
    type: 'single', // single, range, terminal
    time: true, // want display & ctrl hours and minutes or not
    noCalendars: false, // want not display & ctrl calandar, default false
    date: moment('2015-10-01 23:33'), // default date for type single
    range: moment.range(['2015-10-01', '2015-10-08']), // default range for type range or terminal
    minDate: moment('2015-09-30'), // limit minDate
    maxDate: moment(), // limit maxDate
    onSelect: function(date/range) {
      //...
      drp2.set('range', range); // set range in onSelect is no use
    } // callback after select, return date or range with moment and moment-range object
  }

  /* Get a dom object named such as el1 first */
  var drp1 = new DateRangePicker(el1, configs1);
  console.log(drp1.date); // current date for type
  console.log(drp1.range); // current range for type range and terminal
  console.log(drp1.time.hours); // current hours array
  console.log(drp1.time.minutes); // current minutes array

  /* set a value and reload daterangepicker */
  drp1.set('range', moment.range()); // support: date and range, and I'm not ensure set other props are useful. 
  
  /* clear daterangepicker */
  drp1.clear();

  /* support for shortcuts */
  config.shortcuts = {
    el: shortcutsEl, // default: null
    btns: ['today', ...] // sort and which btn will be shown, 
    // default and only those option ['today', 'yesterday', 'lastWeek', 'custom']
  }
  // only support chinese, english and japanese , you can give me a PR for your language.
  // in src/lang.js
  {
    today: 'todayStr', // such as: '今天'
    yesterday: 'yesterdayStr', // such as: '昨天'
    lastWeek: 'lastWeekStr', // for range and terminal. such as: '最近一周'
    lastMonth: 'lastMonthStr', // for range and terminal. such as: '最近一月'
    custom: 'customStr' // such as: '自定义'
  };

  /* support for dimension in single(developing) */
  config.dimension = {
    el: dimensionEl, // default: null
    btns: ['day', ...] // sort and which btn will be shown, 
    // default and only those option ['day', 'week', 'month']
  }
  // only support chinese, english and japanese, you can give me a PR for your language.
  // in src/lang.js
  {
    day: 'dayStr', // such as: '日'
    week: 'weekStr', // such as: '周'
    month: 'monthStr' // such as: '月'
  };

Develop

  $ git clone && make dev && view localhost:8888

bug && suggestion?

Give me issue please~

TODO

Easily transform to angular directive or react component (in new project)