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

feat(core): subtract Durations #16734

Merged
merged 6 commits into from
Oct 29, 2021
Merged

Conversation

jogold
Copy link
Contributor

@jogold jogold commented Sep 30, 2021

Add a .minus() method to Duration.

Closes #16535


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

Add a `.subtract()` method to `Duration`.

Deprecate `.plus()` in favor of `.add()`, feels like a better naming.

Closes aws#16535
@gitpod-io
Copy link

gitpod-io bot commented Sep 30, 2021

@jogold jogold changed the title feat(core): subtract Duration feat(core): subtract Durations Sep 30, 2021
@github-actions github-actions bot added the @aws-cdk/core Related to core CDK functionality label Oct 20, 2021
Copy link
Contributor

@rix0rrr rix0rrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deprecate .plus() in favor of .add(): it feels like a better naming.

I don't agree. What reads better:

  • 3 hours plus 30 minutes
  • 3 hours add 30 minutes

Not to mention that add sounds mutable, whereas plus definitely doesn't:

const x = Duration.hours(3);
x.add(Duration.minutes(30)); // From the name, I can't tell if this mutates x

x.plus(Duration.minutes(30)); // From the name, I can definitely tell this *doesn't* mutate x

Why not rename subtract -> minus ?

@mergify mergify bot dismissed rix0rrr’s stale review October 28, 2021 07:12

Pull request has been modified.

@jogold
Copy link
Contributor Author

jogold commented Oct 28, 2021

Not to mention that add sounds mutable, whereas plus definitely doesn't:

Good point.

@jogold jogold requested a review from rix0rrr October 28, 2021 07:19
@mergify
Copy link
Contributor

mergify bot commented Oct 29, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

1 similar comment
@mergify
Copy link
Contributor

mergify bot commented Oct 29, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 1c75b65
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 7a333b0 into aws:master Oct 29, 2021
@mergify
Copy link
Contributor

mergify bot commented Oct 29, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@jogold jogold deleted the core-duration-subtract branch October 29, 2021 11:31
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
Add a `.minus()` method to `Duration`.

Closes aws#16535


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/core Related to core CDK functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(core): Add Duration.minus method
3 participants