Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate Events on DayLight Savings #251

Open
Shamrockonov opened this issue Mar 13, 2014 · 2 comments
Open

Duplicate Events on DayLight Savings #251

Shamrockonov opened this issue Mar 13, 2014 · 2 comments

Comments

@Shamrockonov
Copy link

Apologies if this has already been posted, but I was unable to find anything relating to it.
Whenever I have a particular event occurring near the end of the month, e.g 31th, I will get a duplicate event shown on the 30th also. My start time and end time are identical, so it should only appear only on the 31st.
Here is an example of the data I'm creating an event with.
{"success":1,"result":[{"id":25689,"title":"event1","url":"index.php?cmd=event1","start":"1396220400000","end":"1396220400000","class":"event-info"},{"id":25732,"title":"event2","url":"index.php?cmd=event2&id=25732","start":"1396220400000","end":"1396220400000","class":"event-info"}]}

Both event start and end times equal Sun, 30 Mar 2014 23:00:00 GMT but both these events are meant to occur on the 31st March 2014 00:00 and am pulling them directly from DB.

Looking further into this, it looks like a daylight savings issue, but am still unsure how to resolve

@venkatsep14
Copy link

I am also in the same boat and any luck on this for you or work arounds.

@davidvarney
Copy link

I don't know if the previous two people found a workaround for this issue or not. What worked for me is detecting when the DST happens and then correcting the event's start time by an hour. I use PHP so right before I add the event to the output array I run it through a simple logic check like so:

$date = '2016-03-14';
$previous_day = date("Y-m-d", strtotime($date . " - 1 day"));
if (date('I', strtotime($previous_day)) == "0" && date('I', strtotime($date)) == "1") {
    $begin_date = strtotime($date . " + 1 hour");
} else {
    $begin_date = strtotime($date);
}

NOTE I have some custom fields in my JSON output

$data[] = array(
    'id' => $id,
    'title' => $title,
    'class' => $class,
    'label' => $label,
    'start' => $begin_date . '000',
    'end' => strtotime($date) . '000'
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants