Skip to content

Commit

Permalink
Fix: #5022 - don't show date differences on 32 bit systems)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisharebest committed Sep 16, 2024
1 parent e6cfb3e commit 8eeae41
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion resources/views/lists/anniversaries-list.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ use Illuminate\Support\Collection;
<?php endif ?>
<div class="indent">
<?= $fact->label() . '' . $fact->date()->display($record->tree(), null, true) ?>
(<?= Registry::timestampFactory()->now()->subtractYears($fact->anniv)->diffForHumans() ?>)
<?php if (PHP_INT_SIZE >= 8 || $fact->anniv <= 100) : ?>
(<?= Registry::timestampFactory()->now()->subtractYears($fact->anniv)->diffForHumans() ?>)
<?php endif ?>
<?php if ($fact->place()->gedcomName() !== '') : ?>
— <a href="<?= e($fact->place()->url()) ?>" title="<?= strip_tags($fact->place()->fullName()) ?>">
<?= $fact->place()->shortName() ?>
Expand Down

3 comments on commit 8eeae41

@raaspt
Copy link
Contributor

@raaspt raaspt commented on 8eeae41 Sep 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition is not correct. It's not that the anniversary date of the event happened more than 100 years ago (which from now on would be 1924, 1925, etc.), but rather that the minimum representable date (timestamp) in 32-bits is 13 DEC 1901 20:45:54 UTC.

@raaspt
Copy link
Contributor

@raaspt raaspt commented on 8eeae41 Sep 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider something like the following so that 32-bit folks don't get less details:
<?php if (PHP_INT_SIZE >= 8 || $fact->date()->gregorianYear() > 1901) : ?>
(<?= Registry::timestampFactory()->now()->subtractYears($fact->anniv)->diffForHumans() ?>)
<?php else : ?>
(<?= I18N::plural('%s year', '%s years', $fact->anniv, I18N::number($fact->anniv)) ?>)
<?php endif ?>

@fisharebest
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I don't have access to a 32 bit system, so couldn't test anything.

Please sign in to comment.