Consistent treatment of user-entered dates based on timezone

Follow-up issue based on conversation here: !123891 (comment 1433707881)

When a user enters in a date, we sometimes have a validation on that date that is related to the "current date". For example, a Personal Access Token cannot have an expiration more than 365 days in the future (or however many days the instance has set for max expiration on PATs).

How we calculate the relative date is unclear.

Example for 2 different users with the same GitLab instance:

User 1

  • User's timezone us GMT (UTC +0)
  • It is currently 07:00 GMT on June 19
  • User's GitLab instance says that a Personal Access Token must have an expiration less than 30 days in the future.
  • Setting expiration to July 18, 29 days after June 19, would be valid.

User 2

  • Another user's timezone is PST (UTC -8)
  • It is currently 23:00 PST on June 18
  • User's GitLab instance says that a Personal Access Token must have an expiration less than 30 days in the future.
  • Setting expiration to July 18, 30 days after June 18, would be valid because it is currently June 19 in UTC.

When we invalidate PATs, I do not believe that we take into account the timezone of the user who created the PAT. So it makes sense to use UTC for these types of calculations. But this might be a bit confusing from a user experience perspective. I am guessing we may have other date calculations in the GitLab app that are not exactly timezone aware.

Edited by 🤖 GitLab Bot 🤖