Skip to content

jQuery expression for filtering input elements using dayjs

Notifications You must be signed in to change notification settings

mu-lib/mu-jquery-dayjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jQuery expression for filtering input elements using dayjs.

Installation

npm install mu-jquery-dayjs
bower install mu-jquery-dayjs

Installation

// AMD
require(["jquery", "mu-jquery-dayjs/jquery.dayjs"], function($, $dayjs) {
  $.expr[":"].dayjs = $dayjs($);
});

// CJS
$.expr[":"].dayjs  = require("mu-jquery-dayjs/jquery.dayjs")($);

// Global
$.expr[":"].dayjs  = window["mu-jquery-dayjs/jquery.dayjs"]($);

Usage

The format for the selecor is <op>(=+-)<time>

Supported op:

  • isSame
  • isBefore
  • isAfter

Supported time

  • =(yyyy-mm-dd) for absolute dates
  • (+|-)\d(years|months|days|minutes|seconds) for relative dates
// Select all elements where the date equals 1999-01-01
$("input[type=date]:dayjs(isSame=1999-01-01)");
// Select all elements where the date is one day ago
$("input[type=date]:dayjs(isSame-1days)");
// Select all elements where the date is one hour from now
$("input[type=date]:dayjs(isSame+1hours)");
// Select all elements where the date is before 1 year from now
$("input[type=date]:dayjs(isBefore-1years)");
// Select all elements where the date is after 1 month from now
$("input[type=date]:dayjs(isAfter+1months)");

About

jQuery expression for filtering input elements using dayjs

Resources

Stars

Watchers

Forks

Packages

No packages published