-
Notifications
You must be signed in to change notification settings - Fork 13
date.js
Can be found at date.js
or date.min.js
. Demo
The date picker's date format is {d:DATE,m:MONTH,y:YEAR}
. Months are zero-indexed and years are in the common era. Dates and months can be outside their range and JavaScript will figure it out like magic (eg date -1 is interpreted to be 2 days before the first day of the month given)
var picker=new DatePicker(start,end,elem);
Creates a new date picker; start
and end
are required dates, and elem
is an optional element that is the wrapper of the date picker.
picker.wrapper // wrapper element
picker.day // the current selected date, null if none selected. can be reassigned
picker.onchange // function that runs whenever the selected date changes
picker.inrange(day) // returns if the given day is within the set day range
These methods and properties are only available with the non-minified version; though the minified version also has these, their names are just letters.
picker.start // beginning of day range
picker.end // end of day range
picker.selectedelem // selected date element
picker.selected // essentially picker.day
picker.header // header element (with the day of the week letters)
picker.dates // wrapper element with the dates
DatePicker.purify(day)
Runs day
through the JavaScript Date
constructor in case one of its values is out of range
DatePicker.css(elem) `position:absolute` `height:1px`;
Applies CSS to elem
using template string magic.
Copy and paste this code into the <head>
tag of your HTML:
<script src="https://orbiit.github.io/gunn-web-app/js/date.min.js" charset="utf-8"></script>