You are here

function timefield_integer_to_time in Timefield 7

Same name and namespace in other branches
  1. 1.0.x timefield.module \timefield_integer_to_time()

Helper function to return time value from a timefield integer.

Parameters

array $settings: Field formatter settings. This is a structured array used to format a date with PHP's date() function. This array has the following keys: -separator The character(s) the go(es) between the hour and minute value -period_separator The character(s) the go(es) between the time string and the period (AM/PM) -period The PHP formatting option for period, or "none" to omit display -hour The PHP formatting option for hour -minute The PHP formatting option for minute @see _timefield_time_part_format() for some possible options. It is worth noting that no assumptions are made about how one wishes to format date output, e.g., 24-hour formatted times are not assumed to not have AM/PM period information.

integer $value: Integer offset from midnight to be converted to human-readable time. This value is basically number of seconds from midnight. If you wish to to show a time +1 day, your value can be greater than 86400.

Return value

string Human-readable time string

6 calls to timefield_integer_to_time()
template_preprocess_timefield in ./timefield.module
Preprocess function for the timefield.
template_preprocess_timefield_weekly_summary_minical_box in ./timefield.module
Template preprocess function for the minical box. Every element added to a minical will be themed with this function.
timefield_field_formatter_settings_summary in ./timefield.module
Implements hook_field_formatter_settings_summary().
timefield_field_load in ./timefield.module
Implements hook_field_load().
timefield_field_widget_form in ./timefield.module
Implements hook_field_widget_form().

... See full list

File

./timefield.module, line 995
Defines a Field API field for time

Code

function timefield_integer_to_time($settings, $value) {
  $format = timefield_build_time_format($settings);
  if (isset($value)) {
    if ($value >= 86400) {
      $value = $value - 86400;
    }
    return date($format, mktime(0, 0, $value));
  }
  else {
    return '';
  }
}