# @royalscome/format

> Time formatting tool and number formatting tool

Latest version **2.0.7** (published 2021-12-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install @royalscome/format
pnpm add @royalscome/format
yarn add @royalscome/format
bun add @royalscome/format
```

## 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 | 2.0.7 |
| Published | 2021-12-23 |
| First published | 2021-08-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 10.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | royalscome |
| Keywords | format, npm, package, royalscome |

## Links

- npm: https://www.npmjs.com/package/@royalscome/format
- Repository: https://github.com/royalscome/format
- Homepage: https://github.com/royalscome/format#readme
- Issues: https://github.com/royalscome/format/issues
- npm.io page: https://npm.io/package/@royalscome/format

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 2.0.7 (latest) — 2021-12-23
- 2.0.6 — 2021-09-01
- 2.0.5 — 2021-09-01
- 2.0.4 — 2021-08-31
- 2.0.3 — 2021-08-31
- 2.0.2 — 2021-08-31
- 2.0.1 — 2021-08-31
- 2.0.0 — 2021-08-31
- 1.0.0 — 2021-08-31

## README

<!--
 * @Description: 
 * @Autor: weiyang
 * @Date: 2021-08-31 15:05:56
 * @LastEditors: weiyang
 * @LastEditTime: 2021-09-01 09:41:23
-->
# @royalscome/format
<hr />

[![avatar](https://img.shields.io/badge/npm-v2.0.4-green)](https://github.com/royalscome/format)
Time formatting tool and number formatting tool

## Install
```
$ npm i @royalscome/format
```

## Usage
```js
import { DateFormat } from "@royalscome/format";


DateFormat.format(new Date(), "yyyy年MM月dd日") // 2021年08月31日

// 具体使用介绍看下表（See the table below for detailed usage）
```

### DateFormat
| 子类名 | 介绍 | 参数 | 示例 |
| - | - | - | - |
| format | 格式化日期 | (time=null,format="yyyy年MM月dd日"),time可传时间戳，标准时间格式，format为想获得的时间格式 | DateFormat.format(new Date(), "yyyy年MM月dd日") // 2021年08月31日 |
| formatDateWithZero | 将日期格式化到当天零时 | (time) | DateFormat.formatDateWithZero(new Date(), "yyyy年MM月dd日") // 2021年08月31日 00:00:00 |
| formatDateWithLast | 将日期格式化到当天结束 | (time) | DateFormat.formatDateWithLast(new Date(), "yyyy年MM月dd日") // 2021年08月31日 23：59：59 |
| getDate | 将非标准格式日期转换为标准时间格式 | (time) | DateFormat.getDate("2021.08.31") // 2021-08-31 |
| getDateWithDot | 将标准时间格式转换为.形式 | (time) | DateFormat.getDateWithDot("2021-08-31") // 2021.08.31 |
| getNowYearAndMonth | 获取当前年和月 | (time) | DateFormat.getNowYearAndMonth(new Date()) // 2021-8 |
| getWeekDate | 获取当前星期几 | 无 | DateFormat.getWeekDate() // 星期三 |
| getMonthWeek | 获取当前月份的第几周 | (time) | 无 |
| formatDateToRule | 格式化时间为今天显示具体时间，昨天显示昨天，昨天以前显示日期 | (time) | 具体看介绍 |
| getDateToNumber | 根据传入数字可正负,得到日期 | (time=null,n) | DateFormat.getDateToNumber(new Date(),-1) // 2021-08-30 |
| compareDate | 比较时间大小 | (startTime, endTime) | 具体使用看介绍 |
| getDiffDate | 计算时间差 | (startTime, endTime, fmt = "dd") | 具体使用看介绍 |

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