Skip to content

Conversation

@ahmadalfy
Copy link

@ahmadalfy ahmadalfy commented Mar 18, 2025

Is it wise to merge increment and decrement into one function, since their implementation is exactly the same?

Or maybe let the step be a number (e.g. 10, not -10) and change the implementation to convert it to negative:

    function decrement(step: number = 1) {
      const type = segment.getType();
      const date = addToPart(type, -step);

      onValueChange(withAllPartsSet(date));
    }

Also, I believe the current tests are flaky and gives different results based on the time of the year when the tests are run. For example, current tests will fail if you run it in December because the increment will increase both the month and the year.

I didn't update the tests because this issue needs to be resolved first. I tried setting the date to an absolute value then I stopped because I'd like to know what you think first.

closes #156

@changeset-bot
Copy link

changeset-bot bot commented Mar 18, 2025

⚠️ No Changeset found

Latest commit: 646cd2a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@logaretm
Copy link
Member

Looks good so far, we just need tests and a patch changeset file which you can generate with pnpm changeset

@logaretm logaretm added the 🩹 ver-patch PR should have a patch version changeset type label Mar 19, 2025
@logaretm logaretm marked this pull request as draft March 22, 2025 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🩹 ver-patch PR should have a patch version changeset type

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TimeField step should increment / decrement by 10 if Shift is pressed

2 participants