#20016wrong age calculating in stdWrap
Description
Function stdWrap.age assumes that year always consist of 365 days. It leads to wrong age calculations when measured in years. Since ver 4.2 we can use negative timestamps so we can store birthdays and then use stdWrap.age to render ages of people, but because of this bug ages are being shown incorectly.
(issue imported from #M10437)
Reviews 8
- 13.4 89208[BUGFIX] Respect leap years in timediff age calculation
- main 89085[BUGFIX] Respect leap years in timediff age calculation
- main 31242[TASK] Rebuild the calcAge functionality
- TYPO3_6-2 31232[BUGIX] Remove deprecationLog for calcAge() function
- main 24635[TASK] Rebuild the calcAge functionality
- main 31236Revert "[TASK] Rebuild the calcAge functionality"
- TYPO3_6-2 31231[TASK] Rebuild the calcAge functionality
- main 23508[BUGFIX] Wrong age calculation in stdWrap
Related issues 5
History 2661
Show 1536 earlier messages
-
Tim Lochmüller commented <span data-processor="relativetime" data-value="2009-05-16T14:30:43+00:00" > 05/16/09, 14:30 </span>
-
Alexander Opitz commented and changed status
NewNeeds Feedback target version <span data-processor="relativetime" data-value="2013-05-08T10:34:19+00:00" > 05/08/13, 10:34 </span>The issue is very old, does this issue exists in newer versions of TYPO3 CMS (4.5 or 6.1)?
-
Chris topher commented and changed status
Needs FeedbackAccepted TYPO3 Version4.26.1 Complexity easy <span data-processor="relativetime" data-value="2013-05-08T14:22:07+00:00" > 05/08/13, 14:22 </span>Tim Lochmüller wrote:
> Replace the 365 in the calcAge function with 365.2425!!!This is still unchanged in ContentObjectRenderer.php.
-
Gerrit Code Review changed status
AcceptedUnder Review <span data-processor="relativetime" data-value="2013-08-31T12:13:00+00:00" > 08/31/13, 12:13 </span> Patch set 1 for branch *master* has been pushed to the review server. It is available at https://review.typo3.org/23508 -
Vladimir Podkovanov commented <span data-processor="relativetime" data-value="2013-08-31T13:59:11+00:00" > 08/31/13, 13:59 </span>
Tim Lochmüller wrote:
> Replace the 365 in the calcAge function with 365.2425!!!
> http://en.wikipedia.org/wiki/Year#Calendar_yearThis doesn’t solve the bug, as around birthday date the age would be rendered incorrectly, so it is still useless for displaying age of people.
For example if current year is leap year then age rendered by stdWrap.age will increase a day before than actual birthday.
So, to correctly fix that should be used PHP date time functions working with actual calendar. -
Alexander Opitz commented and changed status
Under ReviewNew assigned to Ernesto Baschny Complexityeasy<span data-processor="relativetime" data-value="2013-09-02T11:35:08+00:00" > 09/02/13, 11:35 </span>This function calculates the age for given seconds, so you don’t have the qualified dates for that calculation. So the function don’t know when there is a leap year or leap seconds.
The calculation is enough for what it is used inside the core.The function exists as
- TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::calcAge
- TYPO3\CMS\Backend\Utility\BackendUtility::calcAgeTo get the wanted functionality we should implement one new function with an other parameter structure and use DateTime diff. The old functions could be deprecated then.
@Ernesto would you vote for the change? If yes, where to put this one function?
-
Vladimir Podkovanov commented <span data-processor="relativetime" data-value="2013-09-02T12:16:19+00:00" > 09/02/13, 12:16 </span>
Alexander Opitz wrote:
> This function calculates the age for given seconds, so you don’t have the qualified dates for that calculation. So the function don’t know when there is a leap year or leap seconds.Not really. The function uses date in form of UNIX timestamp not just period of time in seconds.
From TSref:
> If enabled with a “1” (number, integer) the content is seen as a date (UNIX-time) and the difference from present time and the content-time is returned as one of these eight variations:Since TYPO3 allows negative timestamps then the age function can be used to display age of people too, if not this bug.
UPDATE: I understood you now, you are talking about calcAge() function and I’m about stdWrap’s age function.
In this case I think better not to use calcAge() in stdWrap’s age calculation, as it is not working with dates.
The bug itself is about stdWrap’s age. -
Alexander Opitz commented <span data-processor="relativetime" data-value="2013-09-02T15:51:54+00:00" > 09/02/13, 15:51 </span>
So the problem is the function:
public function stdWrap_age($content = '', $conf = array()) { $content = $this->calcAge($GLOBALS['EXEC_TIME'] - $content, $conf['age']); return $content; }It only gives the seconds of difference to the real calculation function. So we should solve this with my given proposal.
-
Alexander Opitz commented and changed tracker
BugTask <span data-processor="relativetime" data-value="2013-09-02T15:56:45+00:00" > 09/02/13, 15:56 </span>From #51628
A suggestion from Phillip Gampe: ... should refactor the method to use DateTime->diff(), which should be accurate, but does only exists for PHP 5.3. Thus it cannot go into 4.5. @see http://stackoverflow.com/a/3923228/1234469 I would even suggest that you turn this "bug" into a TASK and we submit this only to 6.2 with the subject "Precise date calculation for stdWrap.age". This should be covered with unit tests of course (which in this case a really simple, because we do not need mocking).
-
Ernesto Baschny commented and changed status
NewAccepted target version <span data-processor="relativetime" data-value="2013-09-02T17:24:00+00:00" > 09/02/13, 17:24 </span>Sounds like a nice idea and using DateTime object would be the way to go. PHP 5.3 and TYPO3 6.2 fits.
A central “calcAge” method (with a better name maybe) could be placed in a new core\Utility\DateTimeUtility which could also hold GeneralUtility::convertMicrotime and GeneralUtility::milliseconds
-
Alexander Opitz commented <span data-processor="relativetime" data-value="2013-09-12T10:52:38+00:00" > 09/12/13, 10:52 </span>
@Ernesto
As you are assigned, do you want to do this? -
Ernesto Baschny commented and changed category removed the assignee <span data-processor="relativetime" data-value="2013-09-12T13:46:37+00:00" > 09/12/13, 13:46 </span>
I would want to, but won’t have the time. I didn’t assign it to myself, you did that. :)
-
Alexander Opitz commented and changed assigned to Alexander Opitz <span data-processor="relativetime" data-value="2013-09-12T14:00:03+00:00" > 09/12/13, 14:00 </span>
Ohh shame on me. :)
-
Alexander Opitz commented <span data-processor="relativetime" data-value="2013-10-12T15:49:01+00:00" > 10/12/13, 15:49 </span>
Another problem is the rounding on some parts, so it is possible that after 1,5 years the value 2 years is shown.
-
Gerrit Code Review changed status
AcceptedUnder Review <span data-processor="relativetime" data-value="2013-10-12T17:55:17+00:00" > 10/12/13, 17:55 </span> Patch set 1 for branch *master* has been pushed to the review server. It is available at https://review.typo3.org/24635 -
Gerrit Code Review <span data-processor="relativetime" data-value="2013-10-12T20:11:49+00:00" > 10/12/13, 20:11 </span> Patch set 2 for branch *master* has been pushed to the review server. It is available at https://review.typo3.org/24635
-
Gerrit Code Review <span data-processor="relativetime" data-value="2013-10-13T13:44:59+00:00" > 10/13/13, 13:44 </span> Patch set 3 for branch *master* has been pushed to the review server. It is available at https://review.typo3.org/24635
-
Gerrit Code Review <span data-processor="relativetime" data-value="2013-10-22T00:49:48+00:00" > 10/22/13, 00:49 </span> Patch set 4 for branch *master* has been pushed to the review server. It is available at https://review.typo3.org/24635
-
Gerrit Code Review pushed patch set 5 for master to change 24635 <span data-processor="relativetime" data-value="2013-11-15T11:51:44+00:00" > 11/15/13, 11:51 </span>
-
Gerrit Code Review pushed patch set 6 for master to change 24635 <span data-processor="relativetime" data-value="2014-03-19T12:07:00+00:00" > 03/19/14, 12:07 </span>
-
Gerrit Code Review pushed patch set 7 for master to change 24635 <span data-processor="relativetime" data-value="2014-06-18T11:03:06+00:00" > 06/18/14, 11:03 </span>
-
Gerrit Code Review pushed patch set 8 for master to change 24635 <span data-processor="relativetime" data-value="2014-06-18T13:04:20+00:00" > 06/18/14, 13:04 </span>
-
Gerrit Code Review pushed patch set 9 for master to change 24635 <span data-processor="relativetime" data-value="2014-06-18T13:16:52+00:00" > 06/18/14, 13:16 </span>
-
Gerrit Code Review pushed patch set 10 for master to change 24635 <span data-processor="relativetime" data-value="2014-06-18T15:32:33+00:00" > 06/18/14, 15:32 </span>
-
Gerrit Code Review pushed patch set 11 for master to change 24635 <span data-processor="relativetime" data-value="2014-06-18T17:41:54+00:00" > 06/18/14, 17:41 </span>
-
Gerrit Code Review pushed patch set 12 for master to change 24635 <span data-processor="relativetime" data-value="2014-06-18T19:52:23+00:00" > 06/18/14, 19:52 </span>
-
Gerrit Code Review pushed patch set 13 for master to change 24635 <span data-processor="relativetime" data-value="2014-06-19T08:59:20+00:00" > 06/19/14, 08:59 </span>
-
Gerrit Code Review pushed patch set 14 for master to change 24635 <span data-processor="relativetime" data-value="2014-06-19T14:17:38+00:00" > 06/19/14, 14:17 </span>
-
Gerrit Code Review pushed patch set 15 for master to change 24635 <span data-processor="relativetime" data-value="2014-06-19T14:28:45+00:00" > 06/19/14, 14:28 </span>
-
Gerrit Code Review pushed patch set 16 for master to change 24635 <span data-processor="relativetime" data-value="2014-06-19T15:47:14+00:00" > 06/19/14, 15:47 </span>
-
Gerrit Code Review pushed patch set 17 for master to change 24635 <span data-processor="relativetime" data-value="2014-06-19T16:50:18+00:00" > 06/19/14, 16:50 </span>
-
Gerrit Code Review pushed patch set 18 for master to change 24635 <span data-processor="relativetime" data-value="2014-06-19T17:18:04+00:00" > 06/19/14, 17:18 </span>
-
Gerrit Code Review pushed patch set 19 for master to change 24635 <span data-processor="relativetime" data-value="2014-06-29T17:51:38+00:00" > 06/29/14, 17:51 </span>
-
Gerrit Code Review pushed patch set 1 for TYPO3_6-2 to change 31231 <span data-processor="relativetime" data-value="2014-06-29T17:52:19+00:00" > 06/29/14, 17:52 </span>
-
Alexander Opitz commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2014-06-29T18:30:28+00:00" > 06/29/14, 18:30 </span>Applied in changeset commit:4c52cb3cfe4f6819a29f1daa064859affe23989d.
-
Helmut Hummel commented and changed status
ResolvedAccepted target version TYPO3 Version6.16.2 <span data-processor="relativetime" data-value="2014-06-29T23:34:47+00:00" > 06/29/14, 23:34 </span>Reverted with: https://review.typo3.org/31236
-
Gerrit Code Review pushed patch set 1 for master to change 31242 status
AcceptedUnder Review <span data-processor="relativetime" data-value="2014-06-30T11:45:12+00:00" > 06/30/14, 11:45 </span> -
Gerrit Code Review <span data-processor="relativetime" data-value="2014-08-03T20:14:49+00:00" > 08/03/14, 20:14 </span> Patch set 2 for branch *master* of project *Packages/TYPO3.CMS* has been pushed to the review server. It is available at http://review.typo3.org/31242
-
Mathias Schreiber changed target version <span data-processor="relativetime" data-value="2014-12-23T19:55:04+00:00" > 12/23/14, 19:55 </span>
-
Alexander Opitz changed status
Under ReviewIn Progress target version <span data-processor="relativetime" data-value="2015-06-10T14:19:30+00:00" > 06/10/15, 14:19 </span> -
Gerrit Code Review changed status
In ProgressUnder Review <span data-processor="relativetime" data-value="2015-07-17T10:06:03+00:00" > 07/17/15, 10:06 </span> Patch set 3 for branch *master* of project *Packages/TYPO3.CMS* has been pushed to the review server. It is available at http://review.typo3.org/31242 -
Gerrit Code Review <span data-processor="relativetime" data-value="2015-08-26T14:26:49+00:00" > 08/26/15, 14:26 </span> Patch set 4 for branch *master* of project *Packages/TYPO3.CMS* has been pushed to the review server. It is available at http://review.typo3.org/31242
-
Benni Mack changed target version <span data-processor="relativetime" data-value="2015-09-24T20:44:39+00:00" > 09/24/15, 20:44 </span>
-
Alexander Opitz commented and changed target version <span data-processor="relativetime" data-value="2015-10-06T16:06:11+00:00" > 10/06/15, 16:06 </span>
Still no information about utility vs. service, so this won’t made it before feature freeze for 7 LTS.
-
Anja Leichsenring changed status
Under ReviewClosed <span data-processor="relativetime" data-value="2016-12-31T13:16:52+00:00" > 12/31/16, 13:16 </span> -
Alexander Opitz commented and changed status
ClosedUnder Review <span data-processor="relativetime" data-value="2016-12-31T20:05:08+00:00" > 12/31/16, 20:05 </span>The state of this issue isn’t changed.
-
Benni Mack changed target version <span data-processor="relativetime" data-value="2017-03-28T19:35:05+00:00" > 03/28/17, 19:35 </span>
-
Susanne Moog changed category <span data-processor="relativetime" data-value="2017-10-27T13:16:22+00:00" > 10/27/17, 13:16 </span>
-
Alexander Opitz commented and changed status
Under ReviewNew done100 %0 % <span data-processor="relativetime" data-value="2017-11-30T14:25:30+00:00" > 11/30/17, 14:25 </span>With #83171 intl support was integrated, so we can do this patches with intl support.
-
Gerrit Code Review pushed patch set 2 for main to change 89085 status
NewUnder Review <span data-processor="relativetime" data-value="2025-04-12T16:56:49+00:00" > 04/12/25, 16:56 </span> -
Gerrit Code Review pushed patch set 3 for main to change 89085 <span data-processor="relativetime" data-value="2025-04-12T19:23:57+00:00" > 04/12/25, 19:23 </span>
-
Gerrit Code Review pushed patch set 4 for main to change 89085 <span data-processor="relativetime" data-value="2025-04-12T19:25:20+00:00" > 04/12/25, 19:25 </span>
-
Gerrit Code Review pushed patch set 5 for main to change 89085 <span data-processor="relativetime" data-value="2025-04-12T19:28:30+00:00" > 04/12/25, 19:28 </span>
-
Gerrit Code Review pushed patch set 6 for main to change 89085 <span data-processor="relativetime" data-value="2025-04-12T21:03:37+00:00" > 04/12/25, 21:03 </span>
-
Gerrit Code Review pushed patch set 7 for main to change 89085 <span data-processor="relativetime" data-value="2025-04-14T13:22:20+00:00" > 04/14/25, 13:22 </span>
-
Gerrit Code Review pushed patch set 8 for main to change 89085 <span data-processor="relativetime" data-value="2025-04-14T16:15:59+00:00" > 04/14/25, 16:15 </span>
-
Gerrit Code Review pushed patch set 9 for main to change 89085 <span data-processor="relativetime" data-value="2025-04-15T15:42:50+00:00" > 04/15/25, 15:42 </span>
-
Gerrit Code Review pushed patch set 10 for main to change 89085 <span data-processor="relativetime" data-value="2025-04-15T15:51:54+00:00" > 04/15/25, 15:51 </span>
-
Gerrit Code Review pushed patch set 1 for 13.4 to change 89208 <span data-processor="relativetime" data-value="2025-04-24T05:52:28+00:00" > 04/24/25, 05:52 </span>
-
Benjamin Franzke commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2025-04-24T06:10:10+00:00" > 04/24/25, 06:10 </span>Applied in changeset commit:f79db3e8ee1f8e035f2f3446f8666cabec2780c4.
-
Benni Mack changed status
ResolvedClosed <span data-processor="relativetime" data-value="2025-12-02T14:36:42+00:00" > 12/02/25, 14:36 </span>
Replace the 365 in the calcAge function with 365.2425!!!
http://en.wikipedia.org/wiki/Year#Calendar_year
This reduce the calculation mistake with very “old” calculations against 0.