forked from fponticelli/thx.unit
/
PlankTimeUnit.hx
94 lines (86 loc) · 3.78 KB
/
PlankTimeUnit.hx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package thx.unit.time;
import thx.core.Floats;
// TODO parse string
abstract PlankTimeUnit(Float) {
@:from inline static public function floatToPlankTimeUnit(value : Float) : PlankTimeUnit
return new PlankTimeUnit(value);
function new(value : Float)
this = value;
@:op( -A ) inline public function negate() : PlankTimeUnit
return -this;
@:op( A+B) inline public function add(other : PlankTimeUnit) : PlankTimeUnit
return this + other.toFloat();
@:op( A-B) inline public function subtract(other : PlankTimeUnit) : PlankTimeUnit
return this - other.toFloat();
@:op( A*B) inline public function multiply(other : Float) : PlankTimeUnit
return this * other;
@:op( A/B) inline public function divide(other : Float) : PlankTimeUnit
return this / other;
@:op( A%B) inline public function modulo(other : Float) : PlankTimeUnit
return this % other;
@:op(A==B) inline public function equal(other : PlankTimeUnit) : Bool
return this == other;
public function nearEqual(other : PlankTimeUnit) : Bool
return Floats.nearEqual(this, other.toFloat());
@:op(A!=B) inline public function notEqual(other : PlankTimeUnit) : Bool
return this != other;
@:op( A<B) inline public function less(other : PlankTimeUnit) : Bool
return this < other.toFloat();
@:op(A<=B) inline public function lessEqual(other : PlankTimeUnit) : Bool
return this <= other.toFloat();
@:op( A>B) inline public function more(other : PlankTimeUnit) : Bool
return this > other.toFloat();
@:op(A>=B) inline public function moreEqual(other : PlankTimeUnit) : Bool
return this >= other.toFloat();
@:to inline public function toFloat() : Float
return this;
@:to inline public function toJiffyPhysics() : JiffyPhysics
return this * 1.79666666666667e-20;
@:to inline public function toSvedberg() : Svedberg
return this * 5.39e-32;
@:to inline public function toPicosecond() : Picosecond
return this * 5.39e-33;
@:to inline public function toNanosecond() : Nanosecond
return this * 5.39e-36;
@:to inline public function toShake() : Shake
return this * 5.39e-37;
@:to inline public function toMicrosecond() : Microsecond
return this * 5.39e-39;
@:to inline public function toFourth() : Fourth
return this * 1.94039999998448e-40;
@:to inline public function toMillisecond() : Millisecond
return this * 5.39e-41;
@:to inline public function toThird() : Third
return this * 3.23399999999935e-42;
@:to inline public function toSecond() : Second
return this * 5.39e-44;
@:to inline public function toMinute() : Minute
return this * 8.98333333333333e-46;
@:to inline public function toKe() : Ke
return this * 6.23842592592593e-47;
@:to inline public function toKilosecond() : Kilosecond
return this * 5.39e-47;
@:to inline public function toHour() : Hour
return this * 1.49722222222222e-47;
@:to inline public function toDay() : Day
return this * 6.23842592592593e-49;
@:to inline public function toWeek() : Week
return this * 8.91203703703704e-50;
@:to inline public function toMegasecond() : Megasecond
return this * 5.39e-50;
@:to inline public function toFortnight() : Fortnight
return this * 4.45601851851852e-50;
@:to inline public function toSynodicMonth() : SynodicMonth
return this * 2.11253006659397e-50;
@:to inline public function toTropicalMonth() : TropicalMonth
return this * 2.28333278160557e-50;
@:to inline public function toJulianYear() : JulianYear
return this * 1.70798793317616e-51;
@:to inline public function toGigasecond() : Gigasecond
return this * 5.39e-53;
@:to inline public function toTerasecond() : Terasecond
return this * 5.39e-56;
@:to inline public function toString() : String
return this + symbol;
public static inline var symbol : String = "tP";
}