Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

ceylon.time.Period should be Invertible #709

Closed
dlkw opened this issue Aug 29, 2018 · 4 comments
Closed

ceylon.time.Period should be Invertible #709

dlkw opened this issue Aug 29, 2018 · 4 comments
Assignees
Milestone

Comments

@dlkw
Copy link
Contributor

dlkw commented Aug 29, 2018

The API documentation doesn't mention much on negative Periods, and normalize() does not take them into account (which is probably another issue), but otherwise there doesn't seem to be a restriction concerning negative values for the individual parameters of this class.

So I suggest Period should satisfy Invertible to be able to subtract a Period instance from another.

@luolong luolong self-assigned this Aug 30, 2018
@gavinking gavinking added this to the 1.4.0 beta milestone Sep 10, 2018
@gavinking
Copy link
Contributor

gavinking commented Sep 10, 2018

That sounds like a good idea. It already satisfies Summable and Scalable, so you can already write:

period1 + (-1 ** period2)

To do subtraction. Weird that you can't rewrite that as period1 - period2.

gavinking added a commit that referenced this issue Sep 10, 2018
@gavinking gavinking self-assigned this Sep 10, 2018
@gavinking
Copy link
Contributor

Done. @luolong please check my work :)

@luolong
Copy link
Contributor

luolong commented Sep 14, 2018

Looks good to me.

@gavinking
Copy link
Contributor

Great, thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants