function xmlsitemap_calculate_changefreq in XML sitemap 7.2
Same name and namespace in other branches
- 8 xmlsitemap.module \xmlsitemap_calculate_changefreq()
- 6.2 xmlsitemap.module \xmlsitemap_calculate_changefreq()
- 2.x xmlsitemap.module \xmlsitemap_calculate_changefreq()
Calculates the average interval between UNIX timestamps.
@codingStandardsIgnoreStart
Parameters
array $timestamps: An array of UNIX timestamp integers.
Return value
int An integer of the average interval.
2 calls to xmlsitemap_calculate_changefreq()
- XMLSitemapUnitTest::testCalculateChangefreq in ./
xmlsitemap.test - Tests for xmlsitemap_calculate_changereq().
- xmlsitemap_node_create_link in xmlsitemap_node/
xmlsitemap_node.module - Create a sitemap link from a node.
File
- ./
xmlsitemap.module, line 1378 - xmlsitemap XML sitemap
Code
function xmlsitemap_calculate_changefreq($timestamps) {
// @codingStandardsIgnoreEnd
sort($timestamps);
$count = count($timestamps) - 1;
$diff = 0;
for ($i = 0; $i < $count; $i++) {
$diff += $timestamps[$i + 1] - $timestamps[$i];
}
return $count > 0 ? round($diff / $count) : 0;
}