# @wdcjs/zilean

> 一个简易的时间库，基于 manba 封装

Latest version **0.0.15** (published 2022-12-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install @wdcjs/zilean
pnpm add @wdcjs/zilean
yarn add @wdcjs/zilean
bun add @wdcjs/zilean
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.15 |
| Published | 2022-12-27 |
| First published | 2022-01-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 12.0.0 |
| Dependencies | 1 |
| Unpacked size | 57.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | watsonhaw |
| Maintainers | watsonhaw |
| Keywords | manba, remax, react |

## Links

- npm: https://www.npmjs.com/package/@wdcjs/zilean
- npm.io page: https://npm.io/package/@wdcjs/zilean

## Dependencies (1)

- [manba](https://npm.io/package/manba.md) ^1.3.5

## 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

- 0.0.15 (latest) — 2022-12-27
- 0.0.14 — 2022-12-26
- 0.0.13 — 2022-03-27
- 0.0.12 — 2022-03-27
- 0.0.11 — 2022-03-26
- 0.0.10 — 2022-03-26
- 0.0.9 — 2022-02-11
- 0.0.8 — 2022-02-11
- 0.0.7 — 2022-01-24
- 0.0.6 — 2022-01-22
- 0.0.5 — 2022-01-13
- 0.0.4 — 2022-01-12
- 0.0.3 — 2022-01-12
- 0.0.2 — 2022-01-12
- 0.0.1 — 2022-01-09

## README

# @wdcjs/zilean

zilean (时间守护者 基兰) 是一个基于 manba 封装 使用 typescript 编写的简易的时间库。

## 快速上手

安装依赖

```bash
$ npm install @wdcjs/zilean
or
$ yarn add @wdcjs/zilean
```

在 React / Remax 中使用

Demo

```jsx
import {Zilean} from '@wdcjs/zilean'

export default Demo = () => {
    // 获取当前年份
    console.log(Zilean.getYear())
    // 获取当前月份
    console.log(Zilean.getMonth())
    // 获取当前是周几
    console.log(Zilean.getDay())
    // 获取当前是几号
    console.log(Zilean.getDate())
    // 获取指定周天数
    console.log(Zilean.getMothDays(2022, 1))
    // 获取指定周天数
    console.log(Zilean.getWeeksDate(2022, 1, 1))
    // 获取指定月份 1号是星期几
    console.log(Zilean.getMothStartDay(2022, 1))
    // 日期对比
    console.log(Zilean.getMothEndDay(2022, 1))
    // 两个日期对比
    console.log(Zilean.compare('2022-01-01', '2022-01-02'))
    // 获取指定天数是星期几 2021/1/1 是周六, date 日期是从 0 开始并且为周日为起始天
    console.log(Zilean.getMothDay(2022, 1, 1))
    // 日期是否在开始和结束范围内 true
    console.log(Zilean.during('2022-01-01', '2022-01-03', '2022-01-02'))
    // 日期是否在开始和结束范围内 false
    console.log(Zilean.during('2022-01-01', '2022-01-03', '2022-01-04'))
    // 获取日期区间内的日期数组 , 支持传入 disableDate 默认为空数组 
    // 返回 ['2022-01-01','2022-01-02','2022-01-03','2022-01-04','2022-01-06']
    console.log(Zilean.during('2022-01-01', '2022-01-06', disableDate = ['2022-01-05']))
    // 获取月份区间内的月份数组 支持传入 disableMonth 默认为空数组
    // 返回 ['2022-01','2022-03','2022-04','2022-05','2022-06']
    console.log(Zilean.getDuringMonth('2022-01', '2022-06', ['2022-02']));
    // 获取当月的节日日期 
    /**
     * 返回数组
     *
     * [
     * { normal: '初七', festival: '元旦', year: 2020, month: 1, day: 1 },
     * { normal: '初八', year: 2020, month: 1, day: 2 },
     * { normal: '初九', year: 2020, month: 1, day: 3 },
     * { normal: '十日', year: 2020, month: 1, day: 4 },
     * { normal: '十一', year: 2020, month: 1, day: 5 },
     * { normal: '十二', year: 2020, month: 1, day: 6 },
     * { normal: '十三', year: 2020, month: 1, day: 7 }
     * ]
     */
    console.log(Zilean.getLunarDate(2020, 1, 1))
    /**
     *
     * 获取当前一周日期(从周一开始),如果不传参默认为当前日期
     * ['2022-3-14',
     '2022-3-15',
     '2022-3-16',
     '2022-3-17',
     '2022-3-18',
     '2022-3-19',
     '2022-3-20',
     * ]
     */

    console.log(Zilean.getNowWeek('2022-03-20'))
    /**
     * '获取当前一周时间(含天数和日期)
     * [
     {day: '周一', date: '2022-10-03'},
     {day: '周二', date: '2022-10-04'},
     {day: '周三', date: '2022-10-05'},
     {day: '周四', date: '2022-10-06'},
     {day: '周五', date: '2022-10-07'},
     {day: '周六', date: '2022-10-08'},
     {day: '周日', date: '2022-10-09'}
     ]
     */
    console.log(Zilean.getNowWeekDate('2022-10-08'))
}
```

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