function moment_weekday_options in Moment.js 8.2
Same name and namespace in other branches
- 7.2 moment.module \moment_weekday_options()
Build an option list from weekdays.
Parameters
string $key: The $key property will be used as key.
int|null $first_day: First day of the week. Sunday = 0.
string $label: The $label property will be used as label.
Return value
array Array of key-value pairs.
2 calls to moment_weekday_options()
- moment_weekday_name_options in ./
moment.module - Option list with machine readable keys.
- moment_weekday_number_options in ./
moment.module - Option list with numeric keys.
File
- ./
moment.module, line 227 - Moment.js integration.
Code
function moment_weekday_options($key = 'name', $first_day = NULL, $label = 'label') {
if ($first_day === NULL) {
// @FIXME
// This looks like another module's variable. You'll need to rewrite this
// call to ensure that it uses the correct configuration object.
//
// $first_day = variable_get('date_first_day', 0);
// $first_day = \Drupal::config('');
}
$weekdays = moment_info_weekdays();
if ($first_day != 0) {
$weekdays = array_merge(array_slice($weekdays, $first_day), array_slice($weekdays, 0, $first_day));
}
$options = [];
foreach ($weekdays as $weekday) {
$options[$weekday[$key]] = $weekday[$label];
}
return $options;
}