JBAS-1377 date.getYMD() avoids clobbering date
authorBill Erickson <berickxx@gmail.com>
Wed, 16 Nov 2016 21:52:22 +0000 (16:52 -0500)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/web/js/dojo/openils/Util.js

index 3482fb6..1696764 100644 (file)
@@ -515,7 +515,12 @@ if(!dojo._hasResource["openils.Util"]) {
     // Returns the provided date as YYYY-MM-DD for the local time zone.
     // If no date is provided, the current date is used.
     openils.Util.getYMD= function(d) {
-        if (!d) d = new Date();
+        if (d) {
+            // avoid clobbering (below) the date object passed by the caller.
+            d = new Date(d.getTime());
+        } else {
+            d = new Date();
+        }
 
         // toISOString returns a UTC date.  Mangle our 'now' date to
         // force its UTC verion to match that of the local version