mirror of
https://github.com/Kingsrook/qqq-frontend-material-dashboard.git
synced 2025-07-18 13:20:43 +00:00
CE-1643 Add a timezone conversion to the formatDate function for the case where it took a string rather than a Date as input, in which case, the new Date() call would be appying a timezone, and making us off-by-one (for some side of the prime merdian i think)
This commit is contained in:
@ -268,7 +268,15 @@ class ValueUtils
|
|||||||
{
|
{
|
||||||
if (!(date instanceof Date))
|
if (!(date instanceof Date))
|
||||||
{
|
{
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// so, a new Date here will interpret the string as being at midnight UTC, but //
|
||||||
|
// the data object will be in the user/browser timezone. //
|
||||||
|
// so "2024-08-22", for a user in US/Central, will be "2024-08-21T19:00:00-0500". //
|
||||||
|
// correct for that by adding the date's timezone offset (converted from minutes //
|
||||||
|
// to millis) back to it //
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////
|
||||||
date = new Date(date);
|
date = new Date(date);
|
||||||
|
date.setTime(date.getTime() + date.getTimezoneOffset() * 60 * 1000)
|
||||||
}
|
}
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
return (`${date.toString("yyyy-MM-dd")}`);
|
return (`${date.toString("yyyy-MM-dd")}`);
|
||||||
|
Reference in New Issue
Block a user