From f686d5a6b1855a9b4760cce87dc1e310d5514fb4 Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Tue, 14 Aug 2018 13:26:20 -0400 Subject: [PATCH] fixing intial widget setup, today's date wasn't working --- js/app.js | 22 +++++++++++++++++----- js/custom/pageSetup.js | 22 +++++++++++++++++----- style.css | 2 +- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/js/app.js b/js/app.js index d7ecbef..c338a90 100644 --- a/js/app.js +++ b/js/app.js @@ -27,7 +27,7 @@ $(document).ready(function () { $("#res-tab-open").attr("id", "res-tab"); } }); - var start, extraDay,currentDate, currentDate2, requiredDate,minDays, departure, stay, d, dd, m, y, bayView = 'vD4ZpIFk4%2b7FyPsaBnkCqP1cBHWnJili9k5D83MqJq4%3d&', + var extraDay,currentDate, currentDate2, requiredDate,minDays, departure, stay, d, dd, m, y, bayView = 'vD4ZpIFk4%2b7FyPsaBnkCqP1cBHWnJili9k5D83MqJq4%3d&', crookedRiver = 'ZhWXD46i2%2fq319vcR%2fcw69rZvA2bz%2fttOOxO9t1%2fBJ0%3d&', adults, kids, @@ -42,6 +42,21 @@ $(document).ready(function () { function getNights(depart, arrive){ return Math.floor((depart - arrive) / (1000*60*60*24)); } + var today = new Date(); + var dd = today.getDate(); + var mm = today.getMonth()+1; //January is 0! + var yyyy = today.getFullYear(); + + if(dd<10) { + dd = '0'+dd + } + + if(mm<10) { + mm = '0'+mm + } + + today = yyyy + '-' + mm + '-' + dd; + let start = `arrival_date=${today}&`; $(document).on('change', '#arriveOff', function () { const _ = $(this); // offset weird timezone issues by replacing - with / @@ -51,7 +66,7 @@ $(document).ready(function () { let year = arrivalDate.getUTCFullYear(); let formattedDate = `${year}-${month}-${day}`; _.val(formattedDate); - start = `arrival_date=${formattedDate}&`; + // weird date incrementer is the only way in vanilla js to roll over to next month instead of going to 8-32-2018 for example let minDate = ((new Date(arrivalDate).valueOf() + + 1000*3600*24) > 9) ? (new Date(arrivalDate).valueOf() + + 1000*3600*24) : `0${(new Date(arrivalDate).valueOf() + + 1000*3600*24)}`; @@ -70,9 +85,6 @@ $(document).ready(function () { } - - - // currentDate = $("#arriveOff").val(); // currentDate = new Date(currentDate); // console.log(currentDate); diff --git a/js/custom/pageSetup.js b/js/custom/pageSetup.js index 995005b..26cb735 100644 --- a/js/custom/pageSetup.js +++ b/js/custom/pageSetup.js @@ -18,7 +18,7 @@ $(document).ready(function () { $("#res-tab-open").attr("id", "res-tab"); } }); - var start, extraDay,currentDate, currentDate2, requiredDate,minDays, departure, stay, d, dd, m, y, bayView = 'vD4ZpIFk4%2b7FyPsaBnkCqP1cBHWnJili9k5D83MqJq4%3d&', + var extraDay,currentDate, currentDate2, requiredDate,minDays, departure, stay, d, dd, m, y, bayView = 'vD4ZpIFk4%2b7FyPsaBnkCqP1cBHWnJili9k5D83MqJq4%3d&', crookedRiver = 'ZhWXD46i2%2fq319vcR%2fcw69rZvA2bz%2fttOOxO9t1%2fBJ0%3d&', adults, kids, @@ -33,6 +33,21 @@ $(document).ready(function () { function getNights(depart, arrive){ return Math.floor((depart - arrive) / (1000*60*60*24)); } + var today = new Date(); + var dd = today.getDate(); + var mm = today.getMonth()+1; //January is 0! + var yyyy = today.getFullYear(); + + if(dd<10) { + dd = '0'+dd + } + + if(mm<10) { + mm = '0'+mm + } + + today = yyyy + '-' + mm + '-' + dd; + let start = `arrival_date=${today}&`; $(document).on('change', '#arriveOff', function () { const _ = $(this); // offset weird timezone issues by replacing - with / @@ -42,7 +57,7 @@ $(document).ready(function () { let year = arrivalDate.getUTCFullYear(); let formattedDate = `${year}-${month}-${day}`; _.val(formattedDate); - start = `arrival_date=${formattedDate}&`; + // weird date incrementer is the only way in vanilla js to roll over to next month instead of going to 8-32-2018 for example let minDate = ((new Date(arrivalDate).valueOf() + + 1000*3600*24) > 9) ? (new Date(arrivalDate).valueOf() + + 1000*3600*24) : `0${(new Date(arrivalDate).valueOf() + + 1000*3600*24)}`; @@ -61,9 +76,6 @@ $(document).ready(function () { } - - - // currentDate = $("#arriveOff").val(); // currentDate = new Date(currentDate); // console.log(currentDate); diff --git a/style.css b/style.css index f346625..caf98bc 100644 --- a/style.css +++ b/style.css @@ -3,5 +3,5 @@ Theme Name: Staffords Author: Gaslight Media Author URI: http://www.gaslightmedia.com Description: A theme for Staffords -Version: 1.0.50 +Version: 1.0.51 */ -- 2.17.1