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.

When I want to change a MERCI reservation status from "unconfirmed" to "confirmed" that is within a few hours from now, the below message is shown:

You cannot change the status to Confirmed for a reservation that has past.

I have created a validation rule which prevent users from inputing a date and time in the past:

I know that it is the time zone problem because when 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

Then when users create a MERCI reservation node, 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 inputed value is 8 hours earlier than the actual time.

CommentFileSizeAuthor
#8 2474859-1.patch970 bytesdarrick
#6 2474859.patch648 bytesdarrick
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

metakel’s picture

Project: Field Validation » MERCI (Manage Equipment Reservations, Checkout and Inventory)
Version: 7.x-2.4 » 7.x-2.x-dev
Issue summary: View changes
metakel’s picture

Further checking the issue, I found that it only have problem upon saving the reservation. The below error will be shown if the reservation time is within the offset of the timezone.

"You cannot change the status to Confirmed for a reservation that has past."

Other than this, the module honours the site's timezone settings.

The field's Time zone handling is set to: "Sites' time zone".

metakel’s picture

Issue tags: +Timezone
darrick’s picture

What are your settings for the PHP Default timezone? It's possible it could be inheriting the OS timezone. Try setting it to your timezone if it's not.

metakel’s picture

Thank you darrick. I found that my php5-fpm's "php.ini" has not set any default timezone.

I have added it back according to the PHP documentation: http://php.net/manual/en/timezones.asia.php

The "Date API System date settings" on the "Status report" now reads:

The timezone has been set to Asia/Hong_Kong. The first day of the week has been set to Sunday. The medium date format type has been set to to Tue, 04/21/2015 - 09:16. You may find it helpful to add new format types like Date, Time, Month, or Year, with appropriate formats, at Date and time settings.

However it does not fix the problem.

darrick’s picture

FileSize
648 bytes

Okay. Try this patch below and let me know if it fixes your issues.

metakel’s picture

Thank you again! It seems that the patch works.

I found that the similar problem arises when I use "auto checked out" and "auto checked in": the status does not change at the right time, but 8 hours (my timezone offset) later.

darrick’s picture

FileSize
970 bytes

Try this patch for the auto checkin/out issue.

  • 52d3dd5 committed on 7.x-2.x
    Issue #2474859 by metakel: The module ignores timezone.
    
darrick’s picture

Status: Active » Needs review

The last submitted patch, 6: 2474859.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 8: 2474859-1.patch, failed testing.

darrick’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.