From 749aca560adb9e3873dfe25e70f2926fe95d53ff Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 16 Apr 2025 21:14:04 -0500 Subject: [PATCH] fix: fix timezone offset bug for datepicker only applies when user manually keys in a date.. hopefully this is a sufficient fix..but it does not actually make sense to me yet, so we'll see.. --- src/wuttaweb/templates/wutta-components.mako | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/wuttaweb/templates/wutta-components.mako b/src/wuttaweb/templates/wutta-components.mako index 59f7d91..fdc8af0 100644 --- a/src/wuttaweb/templates/wutta-components.mako +++ b/src/wuttaweb/templates/wutta-components.mako @@ -339,9 +339,15 @@ } // just need to convert to simple ISO date format here, seems // like there should be a more obvious way to do that? - var year = date.getFullYear() - var month = date.getMonth() + 1 - var day = date.getDate() + // nb. also, not sure if/what i am missing here but + // when user keys in a date, the component must assume + // UTC (?) but the value passed to this method may be + // offset in such a way that a *different date* is + // implied! hence we must convert back to UTC when + // isolating each part.. *shrug* + var year = date.getUTCFullYear() + var month = date.getUTCMonth() + 1 + var day = date.getUTCDate() month = month < 10 ? '0' + month : month day = day < 10 ? '0' + day : day return year + '-' + month + '-' + day