Ilya Gorbunov
3c37bbaf64
Duration: normalize to avoid negative zeroes (KT-44168)
...
The current comparison method of inline classes makes
durations of positive and negative zeroes non-equal.
To avoid that, normalize the duration value upon construction
preventing negative zero being stored.
2020-12-31 19:44:39 +03:00
Ilya Gorbunov
ae6f10df3b
Duration: reject NaN duration values (KT-44168)
2020-12-31 19:44:10 +03:00
Svyatoslav Scherbina
0f4173cdfa
Fix running stdlib tests in worker on Native
...
Add `@SharedImmutable` or `@ThreadLocal` where required.
2020-12-14 19:03:06 +03:00
Alexander Udalov
795d6ab407
Migrate UseExperimental->OptIn in project sources
2020-03-10 12:07:14 +01:00
Ilya Gorbunov
4de9361c37
Introduce Duration.isPositive method
2019-08-16 15:25:57 +03:00
Ilya Gorbunov
d7252548fc
Add symmetric number * duration operators
2019-06-18 19:49:50 +03:00
Ilya Gorbunov
a2b1c537af
Change Duration.toString scientific exponent formatting
...
- use 'e+' for positive exponents in scientific format
2019-06-18 19:49:35 +03:00
Ilya Gorbunov
a5b7c270ae
Change Duration.toString(unit, decimals) formatting
...
- switch to scientific notation when value is too big (greater than 1e14)
- allow at most 12 decimals, larger values are coerced to 12
- use scientific format with exactly two decimals in mantissa in JVM
2019-06-18 19:49:35 +03:00
Ilya Gorbunov
c66740a7ed
Explicit public visibility, SinceKotlin and ExperimentalTime status
...
Use file level ExperimentalTime opt-in in tests.
2019-06-18 04:02:35 +03:00
Ilya Gorbunov
3b989cc815
Avoid using 'D' component in ISO duration string representation
...
Days in ISO have nominal duration, they are not always equal to 24H
2019-06-18 04:02:34 +03:00
Ilya Gorbunov
368452748b
Move convertDurationUnit into Duration companion
2019-06-18 04:02:33 +03:00
Ilya Gorbunov
ca10d13f34
Rename Duration storage property to 'value'
2019-06-18 04:02:33 +03:00
Ilya Gorbunov
365cbb94cd
Change Duration.absoluteValue to property
2019-06-18 04:02:33 +03:00
Ilya Gorbunov
9deac2a591
Rename withComponents to toComponents and add two overloads of them
2019-06-18 04:02:33 +03:00
Ilya Gorbunov
796ad29637
Add shortcuts to convert duration to milliseconds and nanoseconds
2019-06-18 04:02:32 +03:00
Ilya Gorbunov
8004c34e44
Reduce Duration API surface, add top-level docs
...
- toDuration(unit) extension instead of constructors
- toDouble/Long/Int(unit) function instead of inUnits()
- remove static factory functions
- remove MIN_VALUE/MAX_VALUE constants
2019-06-18 04:02:32 +03:00
Ilya Gorbunov
b816f50d4d
Implement and test default string formatting in JVM and JS
...
Relax Duration.toString tests for JS and Native rounding specifics
2019-06-18 04:01:55 +03:00
Ilya Gorbunov
c1f7fd0281
Duration: test toString in particular units
2019-06-18 03:59:52 +03:00
Ilya Gorbunov
b9c56af9ba
Change Duration value storage unit to ns
2019-06-18 03:59:52 +03:00
Ilya Gorbunov
690049c082
Duration unit tests
2019-06-18 03:59:52 +03:00