Comment 5 for bug 2035061

Revision history for this message
Robert Malz (rmalz) wrote :

Thanks Paride for feedback.
1.
Old calculation is a little bit wrong.
It assumes that we have 52 weeks in the year - which is 60*60*24*7*52 -> 31449600 seconds
(31449600 - 1) will result in 51 weeks, 31449600 will result in 0 weeks (it is assuming year has passed).
However year calculation is different, 60*60*24*365 -> 31536000
(31536000 - 1) will result in 0 years, 31536000 will result in 1 year.

Problem is that between 31449600 and 31536000 uptime -p will return 0 for weeks and 0 for years.
To finish this up, we will have incorrect output for 86400s (24h).

With new patch:
upweeks = (int) uptime_secs / (60*60*24*7);
will return 52 weeks for 31449600->31536000

2. I'll try to add some details from this comment to update [REGRESSION POTENTIAL] section.