This commit is contained in:
2020-03-04 00:56:44 +00:00
parent 0ae8016995
commit 616f53989c

View File

@@ -40,33 +40,44 @@ export default {
if (token == null || token.length == 0) { if (token == null || token.length == 0) {
throw "relative-date-filter-calculator: date token is null or empty"; 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 //return object contains the two dates that encompass the time period
//the token represents to the local browser time zone but in UTC //the token represents to the local browser time zone but in UTC
//and iso8601 format //and iso8601 format
var ret = { after: undefined, before: undefined }; 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) { switch (token) {
case "*yesterday*": case "*yesterday*":
//Between Day before yesterday at midnight and yesterday at midnight //Between Day before yesterday at midnight and yesterday at midnight
// dtAfter = RelativeToday.AddDays(-1); ret.after = dtToday
// dtAfter = dtAfter.AddSeconds(-1); .plus({ days: -1, seconds: -1 })
// dtBefore = RelativeToday;//.AddDays(-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; break;
} }
return { after: dtStart, before: dtEnd }; return ret;
} }
//new functions above here //new functions above here
}; };
//LUXON MATH: https://moment.github.io/luxon/docs/manual/zones.html#math-across-dsts //LUXON MATH: https://moment.github.io/luxon/docs/manual/zones.html#math-across-dsts
//https://moment.github.io/luxon/docs/manual/math.html //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 ########################## // //############################################################### OLD SERVER FILTERING CODE ##########################