function partial_date_float in Partial Date 7
Generates a numeric date string.
1 call to partial_date_float()
- _partial_date_field_presave in ./
partial_date.admin.inc - Implements hook_field_presave().
File
- ./
partial_date.module, line 1316 - Defines a date element that allows for any combination of date granularity settings.
Code
function partial_date_float(array $c) {
foreach (partial_date_components(array(
'timezone',
)) as $key => $label) {
if (!isset($c[$key]) || !strlen($c[$key])) {
$c[$key] = 0;
}
elseif ($key != 'year' && $key != 'month') {
// Increment hours, minutes and seconds to allow the module to distintish
// between 0 meaning unset and 1 to 24/60 being the actual values.
// Day is incremented to provide a buffer to add / remove the timezone.
$c[$key] = $c[$key] + 1;
}
}
$date = abs($c['year']) . sprintf('%02s', $c['month']) . sprintf('%02s', $c['day']) . sprintf('%02s', $c['hour']) . sprintf('%02s', $c['minute']) . sprintf('%02s', $c['second']);
// 0 or 1-60
return (double) ltrim($date, '0') * ($c['year'] >= 0 ? 1.0 : -1.0);
}