1 | # moment-weekofmonth
|
2 | [![moment-weekofmonth-CI](https://github.com/swtpumpkin/moment-weekofmonth/workflows/moment-weekofmonth-CI/badge.svg?branch=master)](https://github.com/swtpumpkin/moment-weekofmonth/actions)
|
3 | [![version](https://img.shields.io/npm/v/moment-weekofmonth.svg?style=flat-square)]((http://npm.im/moment-weekofmonth))
|
4 | [![install size](https://packagephobia.now.sh/badge?p=moment-weekofmonth)](https://packagephobia.now.sh/result?p=moment-weekofmonth)
|
5 | [![downloads](https://img.shields.io/npm/dm/moment-weekofmonth.svg?style=flat-square)](https://npm-stat.com/charts.html?package=moment-weekofmonth&from=2020-03-05)
|
6 |
|
7 | Gets the week of the month.
|
8 | Use the moment object to find the week number of the month.
|
9 |
|
10 | ## Installation
|
11 | Install via NPM:
|
12 |
|
13 | ```bash
|
14 | npm install moment moment-weekofmonth
|
15 | ```
|
16 |
|
17 | ## Usage
|
18 |
|
19 | #### Javascript
|
20 | ```javascript
|
21 | var moment = require("moment");
|
22 | var wom = require("moment-weekofmonth");
|
23 | var nowDate = moment(); // 2020-02-29
|
24 |
|
25 | wom(moment('2020-01-01')); // 1
|
26 | wom(nowDate); // 5
|
27 | wom(); // TypeError: Cannot read property 'week' of undefined
|
28 | ```
|
29 |
|
30 | #### TypeScript
|
31 | ```typescript
|
32 | import * as moment from "moment";
|
33 | import * as wom from "moment-weekofmonth";
|
34 |
|
35 | const nowDate = moment(); // 2020-02-29
|
36 |
|
37 | wom(moment('2020-01-01')); // 1
|
38 | wom(nowDate); // 5
|
39 | wom(); // TypeError: Cannot read property 'week' of undefined```
|
40 | ```
|