# s94-inputdate

> 时间选择控件

Latest version **1.0.8** (published 2022-08-12) · ISC license · 0 weekly downloads

## Install

```sh
npm install s94-inputdate
pnpm add s94-inputdate
yarn add s94-inputdate
bun add s94-inputdate
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.8 |
| Published | 2022-08-12 |
| First published | 2022-03-09 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 17.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | 牧人与鱼 |
| Maintainers | s94 |
| Keywords | date, time, web, s94, input, 时间选择, 日期选择, 可视化 |

## Links

- npm: https://www.npmjs.com/package/s94-inputdate
- npm.io page: https://npm.io/package/s94-inputdate

## Dependencies (1)

- [s94-web](https://npm.io/package/s94-web.md) ^1.1.0

## Alternatives

- [@js-joda/timezone](https://npm.io/package/@js-joda/timezone.md) — 383.4K weekly downloads
- [chartjs-adapter-moment](https://npm.io/package/chartjs-adapter-moment.md) — 210.8K weekly downloads
- [strftime](https://npm.io/package/strftime.md) — 171.2K weekly downloads
- [vue-flatpickr-component](https://npm.io/package/vue-flatpickr-component.md) — 115.8K weekly downloads
- [timepicker](https://npm.io/package/timepicker.md) — 51.0K weekly downloads

## Recent versions

- 1.0.8 (latest) — 2022-08-12
- 1.0.7 — 2022-08-07
- 1.0.6 — 2022-08-07
- 1.0.5 — 2022-05-08
- 1.0.4 — 2022-04-23
- 1.0.3 — 2022-04-20
- 1.0.2 — 2022-04-20
- 1.0.1 — 2022-03-09
- 1.0.0 — 2022-03-09

## README

# **s94-inputdate**
> 时间日期选择工具

## **安装**
```
$ npm install s94-inputdate
```
## **使用**
```js
var inputdate = require('s94-inputdate');
$('input[type="text"]').on('click',function(){
	//调起插件界面
	var _this = this;
	inputdate(function(res){
		_this.value = res; //把选择的时间结果，赋值到input里面
	},'Y-M-D H:I:S', this.value); //已input的值作为初始数据
})
```

# **属性和方法**

[inputdate(callback[, fmt, initdate])](#inputdate) 调起时间日期控件界面

[inputdate.init(config)](#inputdate_init) 初始化，或者修改配置

[callback函数接受的数据格式](#callback) 

[fmt说明](#fmt)

<p id="inputdate"></p>

## **inputdate(callback[, fmt, initdate])** 
- callback `Function` 接受时间日期选择的结果回调函数，接受一个对象，查看[详细介绍](#callback)
- fmt `String` 返回的时间字符串格式样式，会根据fmt设定需要启用的控件，(**默认值**:Y-M-D H:I:S)，查看[详细介绍](#fmt)
- initdate `Date|String` 初始化时间，为字符串格式需要和fmt一致，(**默认值**:new Date())
- 返回 `underfind` 
>调起时间日期控件界面
```js
var inputdate = require('s94-inputdate');
$('input[type="text"]').on('click',function(){
	//调起插件界面
	var _this = this;
	inputdate(function(res){
		_this.value = res; //把选择的时间结果，赋值到input里面
	},'Y-M-D H:I:S', this.value); //已input的值作为初始数据
})
```
<p id="inputdate_init"></p>

## **inputdate.init(config)** 
- config `Object` 配置参数
	- color `String` 高亮颜色
	- week `Array` 星期格式，星期天开头，默认['日','一','二','三','四','五','六']
	- month `Array` 月份格式，默认['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月']
	- img_left `String` 切换用的单箭头图片地址
	- img_left2 `String` 切换用的双箭头图片地址
- 返回 `underfind` 
>控件初始化，`inputdate()`执行的时候会自动初始化，该函数一般用于修改配置，自定义控件风格
```js
var inputdate = require('s94-inputdate');
inputdate.init({color: '#f00'});
$('input[type="text"]').on('click',function(){
	//调起插件界面
	var _this = this;
	inputdate(function(res){
		_this.value = res; //把选择的时间结果，赋值到input里面
	},'Y-M-D H:I:S', this.value); //已input的值作为初始数据
})
```

<p id="callback"></p>

## **callback函数接受的数据格式** 
```js
{
	value: "2022-01-25 20:25:33", //根据fmt格式化的时间字符串
	y: 2022, //年份的值{1970-}
	m: 1, //月份的值{1-12}
	d: 25, //当月第几天的值{1-31}
	h: 20, //小时的值{0-23}
	i: 25, //分钟的值{0-59}
	s: 33, //秒的值{0-59}
	Date: `Date`, //时间对象
}
//该对象可以直接当字符串使用，等效于value属性
inputdate(function(res){
	res.value == res; //true
	res.value === res; //false
}); //已input的值作为初始数据
```


<p id="fmt"></p>

## **fmt说明** 
返回的时间字符串格式样式。

字母ymdhis分别表示年月日时分秒，大写为有前置0、小写为没有前置0。

W为中文的星期几、w为星期序列(1为星期一... 7为星期天)

>该参数和 **s94.date(fmt[, time])** 中的fmt相同

---
_Source: https://npm.io/package/s94-inputdate · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
