iamkun / iamkun/dayjs

Feature Request: Week of the month .format('wm')

Open
#927 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

There is a need to get the week of the month. This is just week counted from beginning of the month. eg 2 April is week 1, 9th April is in week 2 and so forth.

Here is a way I propose doing it, which I have been doing that requires advanced format.

```js
const d = dayjs(date);
let wm = d.format('w') - d.startOf('M').format('w') + 1;
```
The proposal is to add this to advanced format plugin as a 'wm' format token.

Contributor guide

Open the contributing guide

Research direction

Start by reading the advanced format plugin and the existing `w` format behavior described in the issue. Add the `wm` token there so dates count weeks from the start of the month, then verify that formatting dates such as 2 April and 9 April produces weeks 1 and 2.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.