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

toSI() degC bug #3118

Merged
merged 4 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/type/unit/Unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -1022,9 +1022,13 @@ export const createUnitClass = /* #__PURE__ */ factory(name, dependencies, ({
// Replace this unit list with the proposed list
ret.units = proposedUnitList

ret.value = null
josdejong marked this conversation as resolved.
Show resolved Hide resolved
ret.fixPrefix = true
ret.skipAutomaticSimplification = true

if (this.value !== null) {
return this.to(ret)
}
return ret
}

Expand Down
1 change: 1 addition & 0 deletions test/unit-tests/type/unit/Unit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1326,6 +1326,7 @@ describe('Unit', function () {
assert.strictEqual(Unit.parse('3 ft').toSI().format(10), '0.9144 m')
assert.strictEqual(Unit.parse('0.111 ft^2').toSI().format(10), '0.01031223744 m^2')
assert.strictEqual(Unit.parse('1 kgf').toSI().toString(), '9.80665 (kg m) / s^2')
assert.strictEqual(Unit.parse('300 degC').toSI().toString(), '573.15 K')
})

it('should return SI units for valueless units', function () {
Expand Down