I am at a time zone of GMT+8. I have properly set the Drupal's system at this time zone. Users will not have their own timezone. The OS (Linux) is set to UTC.
I use the "field validation" module and added the below rule on the reservation field:
Type: Date range 2
Column: value
Cycle of date: Global
Minimum date: now
Maximum date: empty
The field's Time zone handling is set to: "Sites' time zone".
Then when users create a new node of this type, this validator is triggered if the input time is within 8 hours from now. I printed the "Custom error message" with the [value] token, and found that the input date is 8 hours earlier than what the user input. i.e. if the user choose 09:00, the [value] prints 01:00. This means that the module does not consider the timezone offset when validating.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | 2474885-field_validation-date-timezone-7.patch | 2.08 KB | Jorrit |
| #3 | timezone_handling_in_date_range2-2474885-3.patch | 2.43 KB | camil.bancioiu |
Comments
Comment #1
camil.bancioiu commentedSame here. The validator for date fields does not take the timezone into account.
Comment #2
camil.bancioiu commentedThe file
plugins/validator/field_validation_date_range2_validator.inccontains the validator plugin responsible for date fields.The function
validate()should read the field settings and determine what timezone handling is set for the field in question.Comment #3
camil.bancioiu commentedHere's my attempt at adding timezone handling to the date range2 validator.
Comment #4
camil.bancioiu commentedComment #5
smurfxx commentedPatch does not work
Comment #6
metakel commentedComment #7
Jorrit commentedI have a slightly different approach. Patch #3 only works for timezone handling set to User, this patch works for all settings.