Skip to content
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

Correctly count month durations relative to the end of longer months #285

Conversation

lilyinstarlight
Copy link
Contributor

Right now relative month time frames are not calculated correctly if the relative duration would put it past the end of a shorter month causing #281, e.g. something like "May 31 minus 1 month" (see #281 (comment) for more explanation of why)

This PR fixes these sorts of anomalies by correcting "May 31 minus 1 month" to be equal to "April 30" rather than "May 1"

I've added test cases as well to affirm this new expected behavior (and made duration test cases work when two test cases have equivalent duration but relativeTo date is different). Please look through the test cases, though, to make sure these are all intended consequences

Fixes #281

@keithamus keithamus merged commit 7db58b3 into github:main Jun 10, 2024
1 check passed
@keithamus
Copy link
Member

keithamus commented Jun 10, 2024

Thanks for tackling this! Released as v4.4.2!

@lilyinstarlight lilyinstarlight deleted the fix/relative-time-at-end-of-longer-months branch June 10, 2024 13:47
andrewpollock referenced this pull request in google/osv.dev Jun 12, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change | Age | Adoption | Passing |
Confidence |
|---|---|---|---|---|---|---|---|
|  |  | lockFileMaintenance | All locks refreshed |  |  |  |  |
|
[@github/relative-time-element](https://togithub.com/github/relative-time-element)
| dependencies | patch | [`4.4.0` ->
`4.4.2`](https://renovatebot.com/diffs/npm/@github%2frelative-time-element/4.4.0/4.4.2)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/@github%2frelative-time-element/4.4.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@github%2frelative-time-element/4.4.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@github%2frelative-time-element/4.4.0/4.4.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@github%2frelative-time-element/4.4.0/4.4.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| [sass](https://togithub.com/sass/dart-sass) | devDependencies | patch
| [`1.77.0` ->
`1.77.5`](https://renovatebot.com/diffs/npm/sass/1.77.0/1.77.5) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/sass/1.77.5?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/sass/1.77.5?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/sass/1.77.0/1.77.5?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/sass/1.77.0/1.77.5?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| [webpack](https://togithub.com/webpack/webpack) | devDependencies |
minor | [`5.91.0` ->
`5.92.0`](https://renovatebot.com/diffs/npm/webpack/5.91.0/5.92.0) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/webpack/5.92.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/webpack/5.92.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/webpack/5.91.0/5.92.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/webpack/5.91.0/5.92.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

🔧 This Pull Request updates lock files to use the latest dependency
versions.

---

### Release Notes

<details>
<summary>github/relative-time-element
(@&#8203;github/relative-time-element)</summary>

###
[`v4.4.2`](https://togithub.com/github/relative-time-element/releases/tag/v4.4.2)

[Compare
Source](https://togithub.com/github/relative-time-element/compare/v4.4.1...v4.4.2)

#### What's Changed

- Correctly count month durations relative to the end of longer months
by [@&#8203;lilyinstarlight](https://togithub.com/lilyinstarlight) in
[https://github.com/github/relative-time-element/pull/285](https://togithub.com/github/relative-time-element/pull/285)

#### New Contributors

- [@&#8203;lilyinstarlight](https://togithub.com/lilyinstarlight) made
their first contribution in
[https://github.com/github/relative-time-element/pull/285](https://togithub.com/github/relative-time-element/pull/285)

**Full Changelog**:
github/relative-time-element@v4.4.1...v4.4.2

###
[`v4.4.1`](https://togithub.com/github/relative-time-element/releases/tag/v4.4.1)

[Compare
Source](https://togithub.com/github/relative-time-element/compare/v4.4.0...v4.4.1)

#### What's Changed

- fix: remove dollar sign from command by
[@&#8203;o-az](https://togithub.com/o-az) in
[https://github.com/github/relative-time-element/pull/282](https://togithub.com/github/relative-time-element/pull/282)
- Adds flag to optionally hide title attribute by
[@&#8203;lindseywild](https://togithub.com/lindseywild) in
[https://github.com/github/relative-time-element/pull/283](https://togithub.com/github/relative-time-element/pull/283)
- fix: Move `noTitle` conditional. by
[@&#8203;smockle](https://togithub.com/smockle) in
[https://github.com/github/relative-time-element/pull/284](https://togithub.com/github/relative-time-element/pull/284)

#### New Contributors

- [@&#8203;o-az](https://togithub.com/o-az) made their first
contribution in
[https://github.com/github/relative-time-element/pull/282](https://togithub.com/github/relative-time-element/pull/282)
- [@&#8203;lindseywild](https://togithub.com/lindseywild) made their
first contribution in
[https://github.com/github/relative-time-element/pull/283](https://togithub.com/github/relative-time-element/pull/283)
- [@&#8203;smockle](https://togithub.com/smockle) made their first
contribution in
[https://github.com/github/relative-time-element/pull/284](https://togithub.com/github/relative-time-element/pull/284)

**Full Changelog**:
github/relative-time-element@v4.4.0...v4.4.1

</details>

<details>
<summary>sass/dart-sass (sass)</summary>

###
[`v1.77.5`](https://togithub.com/sass/dart-sass/blob/HEAD/CHANGELOG.md#1775)

[Compare
Source](https://togithub.com/sass/dart-sass/compare/1.77.4...1.77.5)

-   Fully trim redundant selectors generated by `@extend`.

###
[`v1.77.4`](https://togithub.com/sass/dart-sass/blob/HEAD/CHANGELOG.md#1774)

[Compare
Source](https://togithub.com/sass/dart-sass/compare/1.77.3...1.77.4)

##### Embedded Sass

- Support passing `Version` input for `fatalDeprecations` as string over
    embedded protocol.

- Fix a bug in the JS Embedded Host where `Version` could be incorrectly
accepted
as input for `silenceDeprecations` and `futureDeprecations` in pure JS.

###
[`v1.77.3`](https://togithub.com/sass/dart-sass/blob/HEAD/CHANGELOG.md#1773)

[Compare
Source](https://togithub.com/sass/dart-sass/compare/1.77.2...1.77.3)

##### Dart API

- `Deprecation.duplicateVariableFlags` has been deprecated and replaced
with
    `Deprecation.duplicateVarFlags` to make it consistent with the
`duplicate-var-flags` name used on the command line and in the JS API.

###
[`v1.77.2`](https://togithub.com/sass/dart-sass/blob/HEAD/CHANGELOG.md#1772)

[Compare
Source](https://togithub.com/sass/dart-sass/compare/1.77.1...1.77.2)

- Don't emit deprecation warnings for functions and mixins beginning
with `__`.

- Allow user-defined functions whose names begin with `_` and otherwise
look
    like vendor-prefixed functions with special CSS syntax.

##### Command-Line Interface

-   Properly handle the `--silence-deprecation` flag.

- Handle the `--fatal-deprecation` and `--future-deprecation` flags for
    `--interactive` mode.

###
[`v1.77.1`](https://togithub.com/sass/dart-sass/blob/HEAD/CHANGELOG.md#1771)

[Compare
Source](https://togithub.com/sass/dart-sass/compare/1.77.0...1.77.1)

-   Fix a crash that could come up with importers in certain contexts.

</details>

<details>
<summary>webpack/webpack (webpack)</summary>

###
[`v5.92.0`](https://togithub.com/webpack/webpack/compare/v5.91.0...34e2561addb0f65a7a6fb0ce7ae1aea4cd1d599f)

[Compare
Source](https://togithub.com/webpack/webpack/compare/v5.91.0...v5.92.0)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 6am on wednesday" in timezone
Australia/Sydney, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config help](https://togithub.com/renovatebot/renovate/discussions) if
that's undesired.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/google/osv.dev).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zOTMuMCIsInVwZGF0ZWRJblZlciI6IjM3LjM5My4wIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbImRlcGVuZGVuY2llcyJdfQ==-->
lunny pushed a commit to go-gitea/gitea that referenced this pull request Jun 12, 2024
… the month (#31331)

I tested and all timestamps work as before.

- Reference github/relative-time-element#285
- Fixes #31197

Signed-off-by: Yarden Shoham <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feb 29th showing as 'yesterday' on March 31
2 participants