So the timezone logic here if it is to work outside of UTC / UTC+1 without noticeable quirks:
The review date is stored as a unix timestamp - as it's a scheduled transition, although the review entity also uses timestamp.
The timestamp is calculated from (the 1 second out and it's a different day) 00:00 which is when the transition is expected to be triggered.
The timestamp should be in the Site Timezone to trigger the transition at 00:00 Site Time.
When the timestamp converted to YYYY-MM-DD on the form it should thus use the Site Timezone.
When the form is saved YYYY-MM-DD should be converted to unix timestamp based on the Site TImezone.
At the moment Drupal runs date_default_timezone_set() with in order of preference: user timezone, site timezone, system timezone. So consistently using strtotime() - including in the test - with a site timezone set, and no user timezone, should consistently return the expected value.
So the timezone logic here if it is to work outside of UTC / UTC+1 without noticeable quirks:
The review date is stored as a unix timestamp - as it's a scheduled transition, although the review entity also uses timestamp.
The timestamp is calculated from (the 1 second out and it's a different day) 00:00 which is when the transition is expected to be triggered.
The timestamp should be in the Site Timezone to trigger the transition at 00:00 Site Time.
When the timestamp converted to YYYY-MM-DD on the form it should thus use the Site Timezone.
When the form is saved YYYY-MM-DD should be converted to unix timestamp based on the Site TImezone.
At the moment Drupal runs date_default_timezone_set() with in order of preference: user timezone, site timezone, system timezone. So consistently using strtotime() - including in the test - with a site timezone set, and no user timezone, should consistently return the expected value.
As soon as a user timezone is thrown into the mix the bets are off; and this is also then the javascript calculation https://github.com/localgovdrupal/localgov_workflows/blob/f1e4f7331fea34e7b3a9b8fdd4d851c09948f337/modules/localgov_review_date/js/review-date.js#L38 of time in the 'testing browser'?
_Originally posted by @ekes in https://github.com/localgovdrupal/localgov_workflows/pull/18#discussion_r725624375_