Skip to content

Inconsistency in Duration.divide#660

Closed
KhraksMamtsov wants to merge 1 commit intoEffect-TS:mainfrom
KhraksMamtsov:duration-inconsistency
Closed

Inconsistency in Duration.divide#660
KhraksMamtsov wants to merge 1 commit intoEffect-TS:mainfrom
KhraksMamtsov:duration-inconsistency

Conversation

@KhraksMamtsov
Copy link
Copy Markdown
Contributor

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

I found that when divided by a negative number, the behavior differs.
which way should this inconsistency be resolved? If it should
The same in v3 (codename bigg)

    return match(self, {
      onMillis: (millis) => {
        if (by === 0) return undefined // ===
        return make(millis / by)
      },
      onNanos: (nanos) => {
        if (by <= 0) return undefined // <=
        try {
          return make(nanos / BigInt(by))
        } catch {
          return undefined
        }
      },
      onInfinity: () => infinity
    })

Related

  • Related Issue #
  • Closes #

@nikelborm
Copy link
Copy Markdown
Contributor

nikelborm commented Oct 15, 2025

codename bigg

😄

@mikearnaldi
Copy link
Copy Markdown
Member

I think this links to the broader topic of negative durations, I think the current design is too restrictive, cc @fubhy @tim-smart

@mikearnaldi
Copy link
Copy Markdown
Member

I think this links to the broader topic of negative durations, I think the current design is too restrictive, cc @fubhy @tim-smart

working on it at: #1249

@IMax153
Copy link
Copy Markdown
Member

IMax153 commented Feb 16, 2026

Closing this as it is superceded by #1249

@IMax153 IMax153 closed this Feb 16, 2026
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.

4 participants