# forenoon

> '日期格式化工具'

Latest version **1.0.5** (published 2019-12-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install forenoon
pnpm add forenoon
yarn add forenoon
bun add forenoon
```

## 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.5 |
| Published | 2019-12-24 |
| First published | 2019-12-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | congqian |
| Maintainers | congqian |
| Keywords | forenoon, date, time, dateFormat |

## Links

- npm: https://www.npmjs.com/package/forenoon
- Repository: https://github.com/congqianv/forenoon
- Homepage: https://github.com/congqianv/forenoon#readme
- Issues: https://github.com/congqianv/forenoon/issues
- npm.io page: https://npm.io/package/forenoon

## Dependencies (1)

- [moment](https://npm.io/package/moment.md) ^2.24.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.5 (latest) — 2019-12-24
- 1.0.4 — 2019-12-23
- 1.0.3 — 2019-12-23
- 1.0.2 — 2019-12-23
- 1.0.1 — 2019-12-23
- 1.0.0 — 2019-12-23

## README

# 时间日期格式化工具

### 安装
```javascript
npm i foremoon --save
npm install
```
---
### 引入
```javascript
const foremoon = require('foremoon')
或
import foremoon from 'foremoon'
```
### 使用方法
+ 格式化时间  
  `foremoon.fmtDateArea(options)`  
  **`options`参数:**  

  | 参数名    | 格式                                         | 默认值     | 说明                                          |
  | --------- | -------------------------------------------- | ---------- | --------------------------------------------- |
  | date      | '2019年11月23日 17:42:19' 或者 1577094139529 | new Date() | 传日期形式需要传入字符串，时间戳要转成Number  |
  | fmtType   | full                                         | full       | 返回格式：2019-11-23 18:18:58                 |
  |           | ymd                                          |            | 年月日，返回格式：2019-11-23                  |
  |           | hms                                          |            | 时分秒，返回格式：18:22:04                    |
  |           | chn                                          |            | 中文年月日，返回格式：2019年11月23日 18:22:33 |
  | connector | -、/                                         | -          | 年月日连接符                                  |

+ 获取一段时间

  `foremoon.fmtDateArea(type, fmtType)`

  **`type`** 参数

  | 参数名 | 返回值                         |
  | ------ | ------------------------------ |
  | week   | [ '2019-12-22', '2019-12-28' ] |
  | month  | [ '2019-12-01', '2019-12-31' ] |
  | year   | '2019-01-01', '2019-12-31' ]   |

  **`fmtType`** 参数：

  | 参数名       | 返回值                         |
  | ------------ | ------------------------------ |
  | 'YYYY-MM-DD' | [ '2019-12-22', '2019-12-28' ] |
  | 'YYYY/MM/DD' | [ '2019/12/22', '2019/12/28' ] |

  **`fmtType`的参数可参照`momentjs`格式** 

+ 获取N天前的日期

  `foremoon.datePreEnd(dayCount, type='day', fmtType)`

  示例：

  ```
  foremoon.datePreEnd(7, 'day', 'YYYY-MM-DD')
  ```

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