main();
function main(){
//var content=input.innerText;
var content=editor.getText();
if (hasformula(content)){
let out=eval(content);
if (Number.isInteger(out)){
//output.innerText =" =" +eval(content);
editor.setText(editor.getText()+" =" +eval(editor.getText()) );
}else{
//eoutput.innerText =" =" +eval(content).toFixed(2);
ditor.setText(editor.getText()+" =" +eval(editor.getText()) );
}
}else{
var nDate=new Date();
var tempdate=nDate.toLocaleString().split(",")[0];
//var txt = input.innerText.replace(/heute/i,tempdate).trim();
var txt = editor.getText().trim();
//Drafts
var regex = new RegExp("([0-9]+\.[0-9]+\.[0-9]{4})\s*([\+\-])\s*(\d*\.*)([d,w,m,y])");
var strd1=txt.match(regex)[1];
var operator=txt.match(regex)[2];
var strd2=txt.match(regex)[3];
var sel=txt.match(regex)[4];
// pattern for evaluate the startdate in
var patt1 = /^(\d+)\.(\d+)\.(\d+)$/;
var sday = strd1.match(patt1)[1];
var smonth = strd1.match(patt1)[2];
var syear = strd1.match(patt1)[3];
if((/^(\d+)\.(\d+)\.(\d+)\s*(\+|-)\s*(\d+)\.(\d+)\.(\d+)[d,w,m,y]$/).test(txt)){
var d=strd1.split(".")[0];
var m=strd1.split(".")[1];
var y=strd1.split(".")[2];
if(!validDate(strd1)) {
alert(strd1 +" ist kein gültiges Datum");
} else if(!validDate(strd2)){
alert(strd2 +" ist kein gültiges Datum");
} else {
var adate=new Date(y,m-1,d);
var dd=strd2.split(".")[0];
var mm=strd2.split(".")[1];
var yy=strd2.split(".")[2];
var bdate=new Date(yy,mm-1,dd)
var difference_ms=adate.getTime()-bdate.getTime();
var one_day=1000*60*60*24;
var out_days=Math.round(difference_ms/one_day);
switch (sel.toLowerCase()) {
case "d":
// output.innerText=" Differenz Tage: " +out_days;
editor.setText(editor.getText()+" = Differenz Tage:" +out_days );
//Drafts Ende
break;
case "w":
var week=Math.round(out_days/7)
//output.innerText = " Differenz : " +week+" Wochen ";
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.