Publication in the morning fails! (2nd patch)

AlexisWilke - October 5, 2008 - 19:58
Project:Announcements
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed
Description

Hi Nancy,

I had a customer asking me why his announcements would not appear (and it took me some time because they did not work he deleted them...)

The reason was simple: he was publishing them in the morning. The mktime(12, ...) was the culprit. To not be hit by the difference between UTC and local time, use gmmktime() instead.

I'm attaching a patch, also I could not test properly since it is afternoon now for me...

And if you need someone to help maintain the code, I guess I could help a bit. 8-)

Thank you.
Alexis

#1

AlexisWilke - October 5, 2008 - 20:00

The actual patch is here.

AttachmentSize
announcements-mktime-6.x-1.x-dev.patch 545 bytes

#2

NancyDru - October 5, 2008 - 22:50

Thank you for this patch. I have to think for a few minutes on this one, but I do see where it is better than what is there. However, it would be based on the server's time zone, not the user's. This may be appropriate.

#3

AlexisWilke - October 5, 2008 - 22:58

Yes. I was thinking I should think about it too... 8-)

I do not think it is correct like that either because it is based on UTC only, not the local server. That is, announcements will be published at midnight UTC, not midnight to the website. And I would think that it would make more sense to get it updated at midnight local time for the owner of the site.

We could also have a setting in the admin screens to define the time at which it should be updated. Then we can add that time to time() and compare with that. This way, it is whatever time the user chooses.

Thank you.

#4

NancyDru - October 6, 2008 - 00:44

Hmm, all servers I have dealt with (including even my local Windows system) are set to GMT. So using "date_default_timezone" (the site timezone) is probably not needed. I think I may be getting myself confused for nothing.

#5

NancyDru - October 6, 2008 - 01:45
Status:needs review» fixed

Fix committed on both branches.

#6

AlexisWilke - October 6, 2008 - 07:41
Title:Publication in the morning fails!» Publication in the morning fails! (2nd patch)
Status:fixed» needs review

Nancy,

Okay, so I think that this assumption is correct:

1) On Edit we want to do: UTC -> User Timezone

2) On Submit we want to do: User Timezone -> UTC

If User Timezone not defined, use Site Timezone. If Site Timezone not defined, use 0 (i.e. as is.)

I'm attaching a patch for that feature. Notice that instead of date(), I'm using gmdate().

And I'm not 100% sure but it seems to me that the announcements_all() function should also use gmdate(). It may not make any difference since under Linux `date +%s` and `date -u +%s` return the same result.

Note that I took the code from: /includes/common.inc around line 3600 found in the format_date() function.

Thank you.
Alexis Wilke

AttachmentSize
announcements-date-6.x-1.x-dev.patch 1.5 KB

#7

NancyDru - October 6, 2008 - 13:58
Status:needs review» fixed

Committed on both branches. BTW, when you submit a patch, it is okay to set the "Assigned" field to yourself.

#8

Anonymous (not verified) - October 20, 2008 - 14:13
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.