<feed xmlns='http://www.w3.org/2005/Atom'>
<title>sunfish.git/opendc-common/src/main/kotlin/org/opendc/common/units/TimeDelta.kt, branch master</title>
<subtitle>The OpenDC BSc thesis repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.denounce.ai/sunfish.git/'/>
<entry>
<title>Unit System v2 (#243)</title>
<updated>2025-03-18T09:31:21+00:00</updated>
<author>
<name>Alessio Leonardo Tomei</name>
<email>122273875+T0mexX@users.noreply.github.com</email>
</author>
<published>2025-03-18T09:31:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.denounce.ai/sunfish.git/commit/?id=46ba81a45f7cb10c7f870bbf6946a46207ee353c'/>
<id>46ba81a45f7cb10c7f870bbf6946a46207ee353c</id>
<content type='text'>
* Separated `Time` unit into `TimeDelta` and `TimeStamp` + small fixes

Addition and subtruction between `Timestamp`s is not allowed, but any
other `Unit` operation/comparison is. `TimeDelta`s can be
added/subtructed to/form `Timestamp`s.

Deserialization of `Timestamp`:
- `Number` -&gt; interpreted as millis from Epoch
- `Instant` (string representation) -&gt; converted to Timestamp
- `Duration` (string representation) -&gt; interpreted as duration since
  Epoch (warn msg is logged)

Deserialization of `TimeDelta` is the same as `Time` was before, with the
diference that when an `Instant` is converted to an timedelta since Epoch
a warning message is logged.

* Unit System v2

- Merged `BoundedPercentage` and `UnboundedPercentage`
- Overrided all operation defined in `Unit` in all subclasses to avoid
  as much as possible value classes being boxed in bytecode. If units are used as generics
  (hence also functions defined in Unit&lt;T&gt;) they are boxed (as double would if used as generic).
- All units companions now subclass `UnitId`, and can be used as keys
  (e.g `Map&lt;UnitId, idk&gt;`), while offering `max` `min` and `zero`
  methods.
- Division between the same unit now returns `Percentage`
- Added `Iterable&lt;T&gt;.averageOfUnitOrNull(selector (T) -&gt; &lt;specific unit&gt;)`
- `ifNeg0ThenPos0()` now is optional and not invoked on every
  constructor
- Now methods in `Unit&lt;T&gt;` are all abstract, forcing override and avoid
  boxing in some cases
- Added `@UnintendedOperation` and `UnitOperationException` for methods
  that must be defined but are not intended for use (e.g. `Timestamp` +
  `Timestamp`)</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* Separated `Time` unit into `TimeDelta` and `TimeStamp` + small fixes

Addition and subtruction between `Timestamp`s is not allowed, but any
other `Unit` operation/comparison is. `TimeDelta`s can be
added/subtructed to/form `Timestamp`s.

Deserialization of `Timestamp`:
- `Number` -&gt; interpreted as millis from Epoch
- `Instant` (string representation) -&gt; converted to Timestamp
- `Duration` (string representation) -&gt; interpreted as duration since
  Epoch (warn msg is logged)

Deserialization of `TimeDelta` is the same as `Time` was before, with the
diference that when an `Instant` is converted to an timedelta since Epoch
a warning message is logged.

* Unit System v2

- Merged `BoundedPercentage` and `UnboundedPercentage`
- Overrided all operation defined in `Unit` in all subclasses to avoid
  as much as possible value classes being boxed in bytecode. If units are used as generics
  (hence also functions defined in Unit&lt;T&gt;) they are boxed (as double would if used as generic).
- All units companions now subclass `UnitId`, and can be used as keys
  (e.g `Map&lt;UnitId, idk&gt;`), while offering `max` `min` and `zero`
  methods.
- Division between the same unit now returns `Percentage`
- Added `Iterable&lt;T&gt;.averageOfUnitOrNull(selector (T) -&gt; &lt;specific unit&gt;)`
- `ifNeg0ThenPos0()` now is optional and not invoked on every
  constructor
- Now methods in `Unit&lt;T&gt;` are all abstract, forcing override and avoid
  boxing in some cases
- Added `@UnintendedOperation` and `UnitOperationException` for methods
  that must be defined but are not intended for use (e.g. `Timestamp` +
  `Timestamp`)</pre>
</div>
</content>
</entry>
</feed>
