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.

Comments

camil.bancioiu’s picture

Same here. The validator for date fields does not take the timezone into account.

camil.bancioiu’s picture

The file plugins/validator/field_validation_date_range2_validator.inc contains 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.

camil.bancioiu’s picture

Here's my attempt at adding timezone handling to the date range2 validator.

camil.bancioiu’s picture

Status: Active » Needs review
smurfxx’s picture

Patch does not work

metakel’s picture

Issue summary: View changes
Jorrit’s picture

I have a slightly different approach. Patch #3 only works for timezone handling set to User, this patch works for all settings.