function weather_cron in Weather 7.3
Same name and namespace in other branches
- 5.6 weather.module \weather_cron()
- 6.5 weather.module \weather_cron()
- 7.2 weather.module \weather_cron()
Implements hook_cron().
Deletes expired forecasts and forecast information.
File
- ./
weather.module, line 36 - Display current weather data from many places in the world.
Code
function weather_cron() {
// Calculate UTC time for yesterday.
// This way, forecasts for western timezones which lag
// behind UTC are not removed prematurely from the database.
$yesterday_utc_time = gmdate('Y-m-d H:i:s', REQUEST_TIME - 86400);
// Delete expired forecasts.
db_delete('weather_forecasts')
->condition('time_to', $yesterday_utc_time, '<=')
->execute();
// Delete expired information.
db_delete('weather_forecast_information')
->condition('next_download_attempt', $yesterday_utc_time, '<=')
->execute();
}