JSFiddle - React, Tailwind, and code Playground

by Michael Dibbets

HTML

<input type="text" id="hello" value="2009-12-01 00:00:00"><input type="text" onfocus="document.getElementById('hello').focus()" value="2009-12-01 00:00:00" >
    
    <BR>
Type t+1d or 01Dec09+1w+1d-4d or anything :-)
        
        Go crazy

JavaScript

if(typeof window.ExitToolBox === 'undefined') {
	window.ExitToolBox = function() {
	}
}
window.ExitToolBox.prototype.datestrings = {'jan':0,'feb':1,'mar':2,'apr':3,'may':4,'jun':5,'jul':6,'aug':7,'sept':8,'okt':9,'nov':10,'dec':11};
window.ExitToolBox.prototype.makeDatePickerField = function(elem) {
	if(!(elem instanceof jQuery)) {
		var elem = $(elem);
	}
	/** 
	 * Methods to "change" the form values into database format and then change it back afterwards the ajax callw as succesfull
	 */
	elem.closest('form').on('oc.beforeRequest', function(e, data) { if(elem.val().trim().length > 0) {elem.val(that.formatDate('yy-mm-dd',that.dateparse(elem.val())));} });
	elem.closest('form').on('ajaxSuccess', function(e, data) {  if(elem.val().trim().length > 0) {elem.val(that.formatDate('ddMy',that.dateparse(elem.val()))); }});
	elem.closest('form').on('ajaxError',function(e, data) {  if(elem.val().trim().length > 0) {elem.val(that.formatDate('ddMy',that.dateparse(elem.val())));}});
	var that = this;
	if(elem.val().trim().length > 0) {
		elem.val(this.formatDate('ddMy',this.dateparse(elem.val())));
	}
	elem.on('change',function(x,data){
						//console.log(x);
						if(elem.val().trim().length > 0) {
							var runupdate = false;
							if(typeof x.originalEvent !== 'undefined') {
								elem.val(that.formatDate('ddMy',that.dateparse(elem.val())));
							}
						}
					});
	elem.datepicker({
		format:'ddMyy',
		forceParse:false,
		clearBtn:true
	});
	return elem;
		
};
window.ExitToolBox.prototype.dateHasBetween = function(strdate) {
	return !(strdate.indexOf('#') === -1);
}
window.ExitToolBox.prototype.getBetweenDates = function(strdate) {
	var strarr = strdate.split(/#/);
	var ret = {start:null,end:null};
	if(strarr.length === 2) {
		ret.start = this.dateparse(strarr[0]);
		ret.end = this.dateparse(strarr[1]);
	}
	return ret;
	
	
}
window.ExitToolBox.prototype.dateparse = function(strdate) {
	/** 20-jun-2010  Or  */
	if((strdate.length == 19 && strdate.indexOf(':')==13 &&...