Returns timestamp select controlls

@param string $name
@param mixed  $value
@param array  $attributes
@return string
495845
public static function selectTimestamp(string $name = '', $value = 0, array $attributes = []): string
    {
        $defaultAttributes = ['method-get' => false, 'time-controll' => true];
        $userAttributes = \array_merge($defaultAttributes, $attributes);
        $timeControll = $userAttributes['time-controll'];
        $isEnabled = !isset($userAttributes['disabled']);
        $userAttributes = static::clearAttributes($userAttributes, ['time-controll']);
        $timezone = \date_default_timezone_get();

        $nameY = \sprintf('%s_y', $name);
        $nameM = \sprintf('%s_m', $name);
        $nameD = \sprintf('%s_d', $name);
        $nameH = \sprintf('%s_h', $name);
        $nameI = \sprintf('%s_i', $name);
        $nameS = \sprintf('%s_s', $name);
        $maxD = 31;

        $valY = $valM = $valD = $valH = $valI = $valS = -1;

        if (\is_array($value)) {
            $valY = $value['y'];
            $valM = $value['m'];
            $valD = $value['d'];
            $valH = \intval(0 + $value['h']);
            $valI = \intval(0 + $value['i']);
            $valS = \intval(0 + $value['s']);
        } elseif ($value != 0) {
            $valY = (new \DateTime('@'.$value))->setTimezone(new \DateTimeZone($timezone))->format('Y');
            $valM = (new \DateTime('@'.$value))->setTimezone(new \DateTimeZone($timezone))->format('n');
            $valD = (new \DateTime('@'.$value))->setTimezone(new \DateTimeZone($timezone))->format('j');
            $valH = \intval((new \DateTime('@'.$value))->setTimezone(new \DateTimeZone($timezone))->format('H'));
            $valI = \intval((new \DateTime('@'.$value))->setTimezone(new \DateTimeZone($timezone))->format('i'));
            $valS = \intval((new \DateTime('@'.$value))->setTimezone(new \DateTimeZone($timezone))->format('s'));
        }

        if ($valY > 0 && $valM > 0) {
            $format = \sprintf('%04s-%02s-01 00:00:00', $valY, $valM);
            $maxD = (int)(new \DateTime($format))->format('t');
        }

        $userAttributes['id'] = $nameY;
        $userAttributes['wrapper-class'] = 'year';
        $selectY = Choice::select($nameY, static::getYears(), [$valY], $userAttributes);

        $userAttributes['id'] = $nameM;
        $userAttributes['wrapper-class'] = 'month';
        $selectM = Choice::select($nameM, static::getMonths(), [$valM], $userAttributes);

        $userAttributes['id'] = $nameD;
        $userAttributes['wrapper-class'] = 'day';
        $selectD = Choice::select($nameD, static::getDays($maxD), [$valD], $userAttributes);

        $selectH = Text::inputHidden($nameH, '00', $userAttributes);
        $selectI = Text::inputHidden($nameI, '00', $userAttributes);
        $selectS = Text::inputHidden($nameS, '00', $userAttributes);

        if ($timeControll === true) {
            $userAttributes['id'] = $nameH;
            $userAttributes['wrapper-class'] = 'hour';
            $selectH = Choice::select($nameH, static::getHours(), [$valH], $userAttributes);

            $userAttributes['id'] = $nameI;
            $userAttributes['wrapper-class'] = 'minute';
            $selectI = Choice::select($nameI, static::getMinutes(), [$valI], $userAttributes);

            $userAttributes['id'] = $nameS;
            $userAttributes['wrapper-class'] = 'second';
            $selectS = Choice::select($nameS, static::getSeconds(), [$valS], $userAttributes);
        }

        $btnTitle = static::getConstant(
            'TXT_PANEL_DATA_FORM_TIMESTAMP_CONTROLL_RESET',
            'TXT_PANEL_DATA_FORM_TIMESTAMP_CONTROLL_RESET'
        );
        $resetBtn = $isEnabled ? Tags::span('', ['class' => 'timestamp-reset', 'title' => $btnTitle]) : '';
        $controll = $selectY.$selectM.$selectD.$selectH.$selectI.$selectS.$resetBtn;

        return Tags::div($controll, ['class' => 'timestamp-controll cf']);
    }
747742
public static function inputTimestamp(string $name = '', $value = 0, array $attributes = []): string
    {
        $defaultAttributes = ['method-get' => false, 'time-controll' => true];
        $userAttributes = \array_merge($defaultAttributes, $attributes);
        $timeControll = $userAttributes['time-controll'];
        $isEnabled = !isset($userAttributes['disabled']);
        $userAttributes = static::clearAttributes($userAttributes, ['time-controll']);
        $timezone = \date_default_timezone_get();

        $nameDate = \sprintf('%s_date', $name);
        $nameTime = \sprintf('%s_time', $name);
        $valDate = $valTime = '';

        if (\is_array($value)) {
            $valDate = $value['date'];
            $valTime = $value['time'];
        } elseif ($value != 0) {
            $valDate = (new \DateTime('@'.$value))->setTimezone(new \DateTimeZone($timezone))->format('Y-m-d');
            $valTime = (new \DateTime('@'.$value))->setTimezone(new \DateTimeZone($timezone))->format('H:i:s');
        }

        $userAttributes['id'] = $nameDate;
        $userAttributes['class'] = 'date';
        $inputDate = Text::inputText($nameDate, $valDate, $userAttributes);

        $userAttributes['id'] = $nameTime;
        $userAttributes['class'] = 'time';
        $inputTime = Text::inputHidden($nameTime, '00:00:00', $userAttributes);

        if ($timeControll === true) {
            $inputTime = Text::inputText($nameTime, $valTime, $userAttributes);
        }

        $btnTitle = static::getConstant(
            'TXT_PANEL_DATA_FORM_TIMESTAMP_CONTROLL_RESET',
            'TXT_PANEL_DATA_FORM_TIMESTAMP_CONTROLL_RESET'
        );
        $resetBtn = $isEnabled ? Tags::span('', ['class' => 'timestamp-reset', 'title' => $btnTitle]) : '';
        $controll = $inputDate.$inputTime.$resetBtn;

        return Tags::div($controll, ['class' => 'timestamp-controll cf']);
    }
704284
protected function fetchCssAttributeSelector($name, $value)
    {
        // if the attribute name starts with ^
        // example: *[^data-]
        if (substr($name, 0, 1) === '^') {
            $xpath = sprintf('@*[starts-with(name(), "%s")]', substr($name, 1));

            return $value === null ? $xpath : sprintf('%s="%s"', $xpath, $value);
        }

        // if the attribute name starts with !
        // example: input[!disabled]
        if (substr($name, 0, 1) === '!') {
            $xpath = sprintf('not(@%s)', substr($name, 1));

            return $xpath;
        }

        switch (substr($name, -1)) {
            case '^':
                $xpath = sprintf('starts-with(@%s, "%s")', substr($name, 0, -1), $value);
                break;
            case '$':
                $xpath = sprintf('ends-with(@%s, "%s")', substr($name, 0, -1), $value);
                break;
            case '*':
                $xpath = sprintf('contains(@%s, "%s")', substr($name, 0, -1), $value);
                break;
            case '!':
                $xpath = sprintf('not(@%s="%s")', substr($name, 0, -1), $value);
                break;
            case '~':
                $xpath = sprintf(
                    'contains(concat(" ", normalize-space(@%s), " "), " %s ")',
                    substr($name, 0, -1),
                    $value
                );
                break;
            default:
                // if specified only the attribute name
                $xpath = $value === null ? '@' . $name : sprintf('@%s="%s"', $name, $value);
                break;
        }

        return $xpath;
    }
1253091
private static function getHtmlAttribute(string $name, $value): string
    {
        if (!self::isset($value)) {
            return '';
        }

        if ($value === true) {
            return $name;
        }

        if (is_array($value)) {
            $value = self::convertAttributeArrayValue($name, $value);
        }

        return sprintf('%s="%s"', $name, static::escape((string) $value));
    }
73176
public function input($type, $name, $value = '', $attributes = array())
    {
        $id = str_replace(array('[', ']'), array('_', ''), $name);

        return $this->tag('input', null)
                    ->set(array('type' => $type, 'value' => $value, 'name' => $name, 'id' => $id))
                    ->set($attributes);
    }
937497
private function getValue(array $attributes, $name, $default = null)
    {
        if (array_key_exists($name, $attributes) && !empty($attributes[$name])) {
            return $attributes[$name];
        }

        return $default;
    }
281495
public static function attribute($name, $value) {
        if ($value instanceof moodle_url) {
            return ' ' . $name . '="' . $value->out() . '"';
        }

        // special case, we do not want these in output
        if ($value === null) {
            return '';
        }

        // no sloppy trimming here!
        return ' ' . $name . '="' . s($value) . '"';
    }
448263
static function laraform($name, $attributes = null, array $data = []) {
        $el = new ElementSelectTwbs($name, $attributes, $data);
        $el->addClass('form-control');
        return $el;
    }
564947
public function attr($name, $value = null)
    {
        if ($value === null) {
            return $this->getAttribute($name);
        }

        return $this->setAttribute($name, $value);
    }
334180
public function getAttribute($attributes, $name) {
        foreach($attributes as $a) {
            if ($a->key == $name) {
                return $a->value;
            }
        }
        return null;
    }
398992
public function time($name = null, $value = null, $attr = null)
    {
        return $this->createInput('time', $name, $value, $attr);
    }
1296558
public static function urlFieldControlGroup($name, $value = '', $htmlOptions = array())
    {
        return self::controlGroup(self::INPUT_TYPE_URL, $name, $value, $htmlOptions);
    }
1326104
public function time($name = null, $value = null) 
	{
		Argument::i()
			->test(1, 'string', 'null')
			->test(2, 'scalar', 'null');
			
		$field = Datetime::i()
			->setOptions('pickDate', false)
			->setOptions('format', 'HH:mm PP');
		
		if(!is_null($name)) {
			$field->setName($name);
		}
		
		if(!is_null($value)) {
			$field->setValue($value);
		}
		
		return $field;
	}
1091343
public static function number($name, $value, array $attributes = array())
    {
        $node = new Node\Number();

        if (!is_null($name)) {
            $attributes['name'] = $name;
        }

        if (!is_null($value)) {
            $attributes['value'] = $value;
        }

        return $node->render($attributes);
    }
617982
public static function calendar($name, $value = null, $options = array())
	{
		static $done;

		if ($done === null)
		{
			$done = array();
		}

		$readonly = isset($options['readonly']) && $options['readonly'] == 'readonly';
		$disabled = isset($options['disabled']) && $options['disabled'] == 'disabled';
		$time     = isset($options['time']) ? (bool)$options['time'] : true;

		$format = 'yy-mm-dd';
		if (isset($options['format']))
		{
			$format = $options['format'] ? $options['format'] : $format;
			unset($options['format']);
		}

		if (!isset($options['class']))
		{
			$options['class'] = 'calendar-field';
		}
		else
		{
			$options['class'] = ' calendar-field';
		}

		if (!$readonly && !$disabled)
		{
			// Load the calendar behavior
			Behavior::calendar();
			Behavior::tooltip();

			$id = self::getIdAttribute($name, $options);

			// Only display the triggers once for each control.
			if (!in_array($id, $done))
			{
				if ($format == 'Y-m-d H:i:s' || $format == '%Y-%m-%d %H:%M:%S')
				{
					$time = true;
				}
				$altformats = array('Y-m-d H:i:s', '%Y-%m-%d %H:%M:%S', 'Y-m-d', '%Y-%m-%d');

				$format = (in_array($format, $altformats) ? 'yy-mm-dd' : $format);

				\App::get('document')->addScriptDeclaration("
					jQuery(document).ready(function($){
						" . ($time ? "$('#" . $id . "').datetimepicker({" : "$('#" . $id . "').datepicker({") . "
							duration: '',
							showTime: true,
							constrainInput: false,
							stepMinutes: 1,
							stepHours: 1,
							altTimeField: '',
							time24h: true,
							dateFormat: '" . $format . "'" . ($time ? ", timeFormat: 'HH:mm:00'" : "") . "
						});
					});
				");

				$done[] = $id;
			}

			return '<span class="input-datetime">' . self::text($name, $value, $options) . '</span>';
		}
		else
		{
			$value = (0 !== (int) $value ? with(new Date($value))->format('Y-m-d H:i:s') : '');

			return self::text($name . 'disabled', (0 !== (int) $value ? with(new Date($value))->format('Y-m-d H:i:s') : ''), $options) .
				   self::hidden($name, $value, $options);
		}
	}
440721
public function addSelect($name, $attributes = array()) {
	
		$control = new FormControlSelect($name, $attributes);
		$this->addControl($control);
	
		return $control;
	
	}
435505
public function getValueAttribute($name, $value = null)
    {
        if (is_null($name)) {
            return $value;
        }

        if (! is_null($value)) {
            return $value;
        }
    }