Skip to content

Commit b2c0d35

Browse files
committed
Fixed vote keys only showing UTC times
1 parent 5a89188 commit b2c0d35

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

logic/keys_vote.php

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -275,12 +275,12 @@ function generateTimeslotKeys($RAID_SLOTS, $raid) {
275275
$keys_time = [];
276276
// Add button for direct start if needed
277277
if(($config->RAID_DIRECT_START && !$config->RAID_RSVP_SLOTS) && $direct_slot != $five_slot && $direct_slot >= $dt_now) {
278-
$keys_time[$direct_slot->format('YmdHi')] = button($direct_slot->format('H:i'), ['vote_time', 'r' => $raid['id'], 't' => $direct_slot->format('YmdHis')]);
278+
$keys_time[$direct_slot->format('YmdHi')] = button(timeslot_label($direct_slot), ['vote_time', 'r' => $raid['id'], 't' => $direct_slot->format('YmdHis')]);
279279
}
280280

281281
// Add button for first five minutes if needed
282282
if($five_slot < $first_slot && $five_plus_slot <= $first_slot && $five_slot >= $dt_now) {
283-
$keys_time[$five_slot->format('YmdHi')] = button($five_slot->format('H:i'), ['vote_time', 'r' => $raid['id'], 't' => $five_slot->format('YmdHis')]);
283+
$keys_time[$five_slot->format('YmdHi')] = button(timeslot_label($five_slot), ['vote_time', 'r' => $raid['id'], 't' => $five_slot->format('YmdHis')]);
284284
}
285285

286286
// Get regular slots
@@ -293,7 +293,7 @@ function generateTimeslotKeys($RAID_SLOTS, $raid) {
293293
debug_log($slot, 'Regular slot:');
294294
// Add regular slot.
295295
if($slot >= $dt_now) {
296-
$keys_time[$slot->format('YmdHi')] = button($slot->format('H:i'), ['vote_time', 'r' => $raid['id'], 't' => $slot->format('YmdHis')]);
296+
$keys_time[$slot->format('YmdHi')] = button(timeslot_label($slot), ['vote_time', 'r' => $raid['id'], 't' => $slot->format('YmdHis')]);
297297
}
298298
// Set last slot for later.
299299
$last_slot = $slot;
@@ -314,17 +314,16 @@ function generateTimeslotKeys($RAID_SLOTS, $raid) {
314314
((isset($last_slot) && $last_extra_slot > $last_slot && $last_extra_slot != $last_slot) ||
315315
!isset($last_slot))) {
316316
// Add last extra slot
317-
$keys_time[$last_extra_slot->format('YmdHi')] = button($last_extra_slot->format('H:i'), ['vote_time', 'r' => $raid['id'], 't' => $last_extra_slot->format('YmdHis')]);
317+
$keys_time[$last_extra_slot->format('YmdHi')] = button(timeslot_label($last_extra_slot), ['vote_time', 'r' => $raid['id'], 't' => $last_extra_slot->format('YmdHis')]);
318318
}
319319

320320
if($config->RAID_RSVP_SLOTS) {
321321
$rsvp_slots = new DatePeriod($direct_slot, new DateInterval('PT15M'), 2);
322322
foreach($rsvp_slots as $slot){
323323
debug_log($slot, 'RSVP slot:');
324+
if($slot < $dt_now) continue;
324325
// Add RSVP slot.
325-
if($slot >= $dt_now) {
326-
$keys_time[$slot->format('YmdHi')] = button($slot->format('H:i'), ['vote_time', 'r' => $raid['id'], 't' => $slot->format('YmdHis')]);
327-
}
326+
$keys_time[$slot->format('YmdHi')] = button(timeslot_label($slot), ['vote_time', 'r' => $raid['id'], 't' => $slot->format('YmdHis')]);
328327
}
329328
}
330329

@@ -337,4 +336,18 @@ function generateTimeslotKeys($RAID_SLOTS, $raid) {
337336
$keys_time[] = button(getPublicTranslation('anytime'), ['vote_time', 'r' => $raid['id']]);
338337
}
339338
return $keys_time;
339+
}
340+
341+
/**
342+
* Generate timeslot label in local time.
343+
* @param DateTime $datetime
344+
* @return string
345+
*/
346+
function timeslot_label($datetime)
347+
{
348+
global $config;
349+
$tz = $config->TIMEZONE;
350+
// Change the timezone of the object without changing it's time
351+
$new = $datetime->setTimezone(new DateTimeZone($tz));
352+
return $new->format('H:i');
340353
}

0 commit comments

Comments
 (0)