mirror of
https://github.com/Kingsrook/qqq-frontend-material-dashboard.git
synced 2025-07-18 21:30:45 +00:00
Better timezone support on query and dropdowns/custom-timeframes.
This commit is contained in:
@ -175,7 +175,10 @@ export default class DataGridUtils
|
||||
filterOperators: filterOperators,
|
||||
};
|
||||
|
||||
if (columnsToRender[field.name])
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
// looks like, maybe we can just always render all columns, and remove this parameter? //
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
if (columnsToRender == null || columnsToRender[field.name])
|
||||
{
|
||||
column.renderCell = (cellValues: any) => (
|
||||
(cellValues.value)
|
||||
|
@ -314,11 +314,7 @@ class FilterUtils
|
||||
{
|
||||
try
|
||||
{
|
||||
let localDate = new Date(param[i]);
|
||||
let month = (1 + localDate.getUTCMonth());
|
||||
let zp = FilterUtils.zeroPad;
|
||||
let toPush = localDate.getUTCFullYear() + "-" + zp(month) + "-" + zp(localDate.getUTCDate()) + "T" + zp(localDate.getUTCHours()) + ":" + zp(localDate.getUTCMinutes()) + ":" + zp(localDate.getUTCSeconds()) + "Z";
|
||||
console.log(`Input date was ${localDate}. Sending to backend as ${toPush}`);
|
||||
let toPush = this.frontendLocalZoneDateTimeStringToUTCStringForBackend(param[i]);
|
||||
rs.push(toPush);
|
||||
}
|
||||
catch (e)
|
||||
@ -336,6 +332,22 @@ class FilterUtils
|
||||
return (rs);
|
||||
};
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Take a string date (w/o a timezone) like that our calendar widgets make,
|
||||
** and convert it to UTC, e.g., for submitting to the backend.
|
||||
*******************************************************************************/
|
||||
public static frontendLocalZoneDateTimeStringToUTCStringForBackend(param: string)
|
||||
{
|
||||
let localDate = new Date(param);
|
||||
let month = (1 + localDate.getUTCMonth());
|
||||
let zp = FilterUtils.zeroPad;
|
||||
let toPush = localDate.getUTCFullYear() + "-" + zp(month) + "-" + zp(localDate.getUTCDate()) + "T" + zp(localDate.getUTCHours()) + ":" + zp(localDate.getUTCMinutes()) + ":" + zp(localDate.getUTCSeconds()) + "Z";
|
||||
console.log(`Input date was ${localDate}. Sending to backend as ${toPush}`);
|
||||
return toPush;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Convert a filter field's value from the style that qqq uses, to the style that
|
||||
** the grid uses.
|
||||
|
@ -353,6 +353,21 @@ class ValueUtils
|
||||
//////////////////////////////////////////////////////////////////
|
||||
return (value + "T00:00");
|
||||
}
|
||||
else if (value.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2})?Z$/))
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// If the passed in string has a Z on the end (e.g., in UTC) - make a Date object - the browser will //
|
||||
// shift the value into the user's time zone, so it will display correctly for them //
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
const date = new Date(value);
|
||||
|
||||
// @ts-ignore
|
||||
const formattedDate = `${date.toString("yyyy-MM-ddTHH:mm")}`
|
||||
|
||||
console.log(`Converted UTC date value string [${value}] to local time value for form [${formattedDate}]`)
|
||||
|
||||
return (formattedDate);
|
||||
}
|
||||
else if (value.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}.*/))
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
Reference in New Issue
Block a user