From 616f53989cb1d4839e4bdb791e6b3e2ac7e77666 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 4 Mar 2020 00:56:44 +0000 Subject: [PATCH] --- .../api/relative-date-filter-calculator.js | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/ayanova/src/api/relative-date-filter-calculator.js b/ayanova/src/api/relative-date-filter-calculator.js index 0816a12c..11613638 100644 --- a/ayanova/src/api/relative-date-filter-calculator.js +++ b/ayanova/src/api/relative-date-filter-calculator.js @@ -40,33 +40,44 @@ export default { if (token == null || token.length == 0) { throw "relative-date-filter-calculator: date token is null or empty"; } - //Luxon object: window.$gz.DateTime //return object contains the two dates that encompass the time period //the token represents to the local browser time zone but in UTC //and iso8601 format var ret = { after: undefined, before: undefined }; + var dtNow = window.$gz.DateTime.local(); + var dtToday = window.$gz.DateTime.local(dtNow.year, dtNow.month, dtNow.day); - var dtStart = window.$gz.DateTime.local() - .toUTC() - .toString(); - var dtEnd = window.$gz.DateTime.local().toString(); switch (token) { case "*yesterday*": //Between Day before yesterday at midnight and yesterday at midnight - // dtAfter = RelativeToday.AddDays(-1); - // dtAfter = dtAfter.AddSeconds(-1); - // dtBefore = RelativeToday;//.AddDays(-1); + ret.after = dtToday + .plus({ days: -1, seconds: -1 }) + .toUTC() + .toString(); + ret.before = dtToday.toUTC().toString(); + break; + case "*today*": + //Between yesterday at midnight and tommorow at midnight + ret.after = dtToday + .plus({ seconds: -1 }) + .toUTC() + .toString(); + ret.before = dtToday + .plus({ days: 1 }) + .toUTC() + .toString(); break; } - return { after: dtStart, before: dtEnd }; + return ret; } //new functions above here }; //LUXON MATH: https://moment.github.io/luxon/docs/manual/zones.html#math-across-dsts //https://moment.github.io/luxon/docs/manual/math.html +//luxon api ref: https://moment.github.io/luxon/docs/class/src/datetime.js~DateTime.html // //############################################################### OLD SERVER FILTERING CODE ##########################