You are here

function xmlsitemap_calculate_changefreq in XML sitemap 6.2

Same name and namespace in other branches
  1. 8 xmlsitemap.module \xmlsitemap_calculate_changefreq()
  2. 7.2 xmlsitemap.module \xmlsitemap_calculate_changefreq()
  3. 2.x xmlsitemap.module \xmlsitemap_calculate_changefreq()

Calculates the average interval between UNIX timestamps.

Parameters

$timestamps: An array of UNIX timestamp integers.

Return value

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 1173
Main file for the xmlsitemap module.

Code

function xmlsitemap_calculate_changefreq($timestamps) {
  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;
}