Task #20016
openwrong age calculating in stdWrap
0%
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)
Updated by Tim Lochmüller over 15 years ago
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.
Updated by Alexander Opitz over 11 years ago
- Status changed from New to Needs Feedback
- Target version deleted (
0)
The issue is very old, does this issue exists in newer versions of TYPO3 CMS (4.5 or 6.1)?
Updated by Chris topher over 11 years ago
- Status changed from Needs Feedback to Accepted
- TYPO3 Version changed from 4.2 to 6.1
- Complexity set to easy
Tim Lochmüller wrote:
Replace the 365 in the calcAge function with 365.2425!!!
This is still unchanged in ContentObjectRenderer.php.
Updated by Gerrit Code Review over 11 years ago
- Status changed from Accepted to Under Review
Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/23508
Updated by Vladimir Podkovanov over 11 years ago
Tim Lochmüller wrote:
Replace the 365 in the calcAge function with 365.2425!!!
http://en.wikipedia.org/wiki/Year#Calendar_year
This 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.
Updated by Alexander Opitz over 11 years ago
- Status changed from Under Review to New
- Assignee set to Ernesto Baschny
- Complexity deleted (
easy)
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::calcAge
To 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?
Updated by Vladimir Podkovanov over 11 years ago
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.
Updated by Alexander Opitz over 11 years ago
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.
Updated by Alexander Opitz over 11 years ago
- Tracker changed from Bug to Task
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).
Updated by Ernesto Baschny over 11 years ago
- Status changed from New to Accepted
- Target version set to 6.2.0
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
Updated by Alexander Opitz about 11 years ago
@Ernesto
As you are assigned, do you want to do this?
Updated by Ernesto Baschny about 11 years ago
- Category set to Content Rendering
- Assignee deleted (
Ernesto Baschny)
I would want to, but won't have the time. I didn't assign it to myself, you did that. :)
Updated by Alexander Opitz about 11 years ago
Another problem is the rounding on some parts, so it is possible that after 1,5 years the value 2 years is shown.
Updated by Gerrit Code Review about 11 years ago
- Status changed from Accepted to Under Review
Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/24635
Updated by Gerrit Code Review about 11 years ago
Patch set 2 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/24635
Updated by Gerrit Code Review about 11 years ago
Patch set 3 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/24635
Updated by Gerrit Code Review about 11 years ago
Patch set 4 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/24635
Updated by Gerrit Code Review about 11 years ago
Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/24635
Updated by Gerrit Code Review over 10 years ago
Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/24635
Updated by Gerrit Code Review over 10 years ago
Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/24635
Updated by Gerrit Code Review over 10 years ago
Patch set 8 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/24635
Updated by Gerrit Code Review over 10 years ago
Patch set 9 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/24635
Updated by Gerrit Code Review over 10 years ago
Patch set 10 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/24635
Updated by Gerrit Code Review over 10 years ago
Patch set 11 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/24635
Updated by Gerrit Code Review over 10 years ago
Patch set 12 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/24635
Updated by Gerrit Code Review over 10 years ago
Patch set 13 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/24635
Updated by Gerrit Code Review over 10 years ago
Patch set 14 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/24635
Updated by Gerrit Code Review over 10 years ago
Patch set 15 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/24635
Updated by Gerrit Code Review over 10 years ago
Patch set 16 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/24635
Updated by Gerrit Code Review over 10 years ago
Patch set 17 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/24635
Updated by Gerrit Code Review over 10 years ago
Patch set 18 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/24635
Updated by Gerrit Code Review over 10 years ago
Patch set 19 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/24635
Updated by Gerrit Code Review over 10 years ago
Patch set 1 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/31231
Updated by Alexander Opitz over 10 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 4c52cb3cfe4f6819a29f1daa064859affe23989d.
Updated by Helmut Hummel over 10 years ago
- Status changed from Resolved to Accepted
- Target version changed from 6.2.0 to next-patchlevel
- TYPO3 Version changed from 6.1 to 6.2
Reverted with: https://review.typo3.org/31236
Updated by Gerrit Code Review over 10 years ago
- Status changed from Accepted to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/31242
Updated by Gerrit Code Review over 10 years ago
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
Updated by Mathias Schreiber almost 10 years ago
- Target version changed from next-patchlevel to 7.2 (Frontend)
Updated by Alexander Opitz over 9 years ago
- Status changed from Under Review to In Progress
- Target version changed from 7.2 (Frontend) to 7.5
Updated by Gerrit Code Review over 9 years ago
- Status changed from In Progress to Under Review
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
Updated by Gerrit Code Review over 9 years ago
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
Updated by Benni Mack about 9 years ago
- Target version changed from 7.5 to 7 LTS
Updated by Alexander Opitz about 9 years ago
- Target version changed from 7 LTS to 8 LTS
Still no information about utility vs. service, so this won't made it before feature freeze for 7 LTS.
Updated by Anja Leichsenring almost 8 years ago
- Status changed from Under Review to Closed
Updated by Alexander Opitz almost 8 years ago
- Status changed from Closed to Under Review
The state of this issue isn't changed.
Updated by Benni Mack over 7 years ago
- Target version changed from 8 LTS to Candidate for Major Version
Updated by Susanne Moog about 7 years ago
- Category changed from Content Rendering to Frontend
Updated by Alexander Opitz about 7 years ago
- Status changed from Under Review to New
- % Done changed from 100 to 0
With #83171 intl support was integrated, so we can do this patches with intl support.