-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for month/months and weeks #57
Comments
A month doesn't have a fixed duration, it can be 28, 29, 30 or 31 days.. But still when you ask google "how many days in a month" the answer is 30.4167 days But because a (julian) year defined as 365.25 days (source: IAU.org) Should we add month unit? Pros: It's convenient and some of us need it |
I’d disagree about having it available, and would instead recommend |
Weeks are in #55 |
This is a hard one, because the convenience is nice and the expectation is there -- e.g.: "why do you support years but not months?", but I agree with @BurntCaramel. Supporting months could easily violate the principle of least surprise for people who don't look at the source. Also, thanks to @leo for #55 -- I was midway into writing a PR when it occurred to me to check existing ones. =P |
Is it worth just putting a note in the readme that month can be achieved with 28 days or 4 weeks? |
My 2 cents:
|
@julien-f It's true that both years and days have a fuzz-factor, but it's a smaller amount of change over a longer period of time, and there's widespread agreement on how to represent their "standard" duration (or else this library wouldn't exist). However, months are weird, and expectations vary on what should happen when Months have fixed variability in length (is that the right way to describe it?) per instance of each month. I think there's potential for surprise when hardcoding a fixed duration because everyone knows they are not fixed. I think documentation saying "we chose X days to represent the length of one month" is fine, but it essentially hobbles the month unit to a narrow use case and assumes a lot of agreement already exists around the concept of a month's duration. Sorry, had to edit - I hit |
I noticed that This is very confusing since I expect I suggest removing conversion of "M" units until there is support to express months. |
At least, until you figure out whether or not to support months, would it be possible for |
My vote is for 1 month to just be an alias 30 days. My use case is the user typing and running |
* cannot sleep `1 month` - it's 30d vercel/ms#57 * Update 2022-01-24-workflows-part-I.md * Update workflows.md Co-authored-by: swyx <[email protected]>
Upstream issue: vercel#57
Any updates on this? |
I ended up making my own that supports months as 30 days. Check it out and see if it helps you. |
A month is not a fixed 30 days, nor is a year 364.25 days, and I do not understand how time works on your planets. On Earth, we have 365 days, and in a leap year, 366 days in a year. I created a package to solve a decade-old problem. The package, named Here are some usage examples: ms('1mon') // 2678400000 - The result depends on the current date
ms({ month: 1 }) // ...
ms('1mon', { from: new Date('2016-01-01') }) // 2678400000 - 31 days in Jan 2016
ms('1mon', { from: new Date('2017-02-01') }) // 2419200000 - 28 days in Feb 2017
ms('1y', { from: new Date('2016-01-01') }) // 31622400000 - Leap year; 366 days
ms('1y', { from: new Date('2015-01-01') }) // 31536000000 - Non-leap year; 365 days Here are the resources if you are interested: |
Thank you for this package. Will look into it |
No description provided.
The text was updated successfully, but these errors were encountered: