# j-TimePicker

> The component must be called manually or works with j-Input component automatically. This component is a singleton.

Framework: jcomponent20
Product: jComponent 20 (jcomponent@20)
Language: en
Content-SHA256: 453c001d6268617294247689b41b0338e981e0a3dd038febb3b00c7d34abd521
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: components@910ed1a86f6e72b4f031d3ad0dc7844f9fc5cb8e
Review: not-recorded

- supports __dark mode__


__Configuration__:

- `seconds {Boolean}` optional, enables seconds (default: `false`)
- `ampm {Boolean}` optional, enables 12 hours time format (default: `false`)

The component must be called manually or works with `j-Input` component automatically. This component is a singleton.

- __important__ add the component under `<body>` element

## Usage

```javascript
var opt = {};

// opt.offsetX {Number}    : adds X offset (default: 0)
// opt.offsetY {Number}    : adds Y offset (default: 0)
// opt.seconds {Boolean}   : shows seconds (default: false)
// opt.ampm    {Boolean}   : shows 12 hours time format (default: false)
// opt.align   {left|center|right} (default: left)

opt.value = new Date();
// or
// opt.value = 'path.to.date' (in this case you don't need to declare "opt.callback")

opt.element = YOUR_ELEMENT;

opt.callback = function(date) {
	console.log(date);
};

// opt.close {Function} optional, this function can determine the closing of TimePicker

SETTER('timepicker/show', opt);
```

Use it with `<ui-component name="timepicker">`. When the component is not loaded yet, jComponent downloads it on first use from the address in `DEF.fallback` (the Componentator CDN by default). Author: Peter Širka. Source: the Componentator components repository, MIT license.

```html example.html
<a href="#timepicker">SHOW TIMEPICKER <ui-bind path="form.date" config="html:value.format('HH\:mm\:ss')"></ui-bind></a>
<ui-component name="timepicker"></ui-component>

<script>
	var form = {};
	form.date = new Date();

	$('a[href="#timepicker"]').on('click', function(e) {
		var opt = {};
		opt.element = this;
		opt.value = 'form.date';
		opt.seconds = true;
		SETTER('timepicker/toggle', opt);
	});
</script>
```
