mirror of
https://github.com/Kingsrook/qqq-frontend-material-dashboard.git
synced 2025-07-18 13:20:43 +00:00
Submit date-times in UTC. delete date-times from what gets submitted if it isn't changed (to try to avoid second-truncation); moved frontendLocalZoneDateTimeStringToUTCStringForBackend from FilterUtils to ValueUtils
This commit is contained in:
@ -373,6 +373,33 @@ class ValueUtils
|
||||
return (value);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
private static zeroPad = (n: number): string =>
|
||||
{
|
||||
if (n < 10)
|
||||
{
|
||||
return ("0" + n);
|
||||
}
|
||||
return (`${n}`);
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
** 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 = ValueUtils.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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
Reference in New Issue
Block a user