@@ -18,6 +18,12 @@ class TimeInterpreter extends MeasurementInterpreter<Time> {
18
18
/// conversions are acceptable, via the [Time.ofDuration] and [Time.asDuration]
19
19
/// methods.
20
20
class Time extends Measurement <Time > {
21
+ /// The [TimeInterpreter] for picoseconds.
22
+ static final TimeInterpreter picoseconds = TimeInterpreter ._(1e12 );
23
+
24
+ /// The [TimeInterpreter] for nanoseconds.
25
+ static final TimeInterpreter nanoseconds = TimeInterpreter ._(1e9 );
26
+
21
27
/// The [TimeInterpreter] for microseconds.
22
28
static final TimeInterpreter microseconds = TimeInterpreter ._(1e6 );
23
29
@@ -63,6 +69,8 @@ class Time extends Measurement<Time> {
63
69
64
70
/// Constructs a [Time] representing the sum of partial amounts.
65
71
Time .of ({
72
+ final num picoseconds = 0 ,
73
+ final num nanoseconds = 0 ,
66
74
final num microseconds = 0 ,
67
75
final num milliseconds = 0 ,
68
76
final num seconds = 0 ,
@@ -71,14 +79,26 @@ class Time extends Measurement<Time> {
71
79
final num days = 0 ,
72
80
final Precision precision = Precision .max,
73
81
}) : this ._(
74
- Time .microseconds._from (microseconds) +
82
+ Time .picoseconds._from (picoseconds) +
83
+ Time .nanoseconds._from (nanoseconds) +
84
+ Time .microseconds._from (microseconds) +
75
85
Time .milliseconds._from (milliseconds) +
76
86
Time .seconds._from (seconds) +
77
87
Time .minutes._from (minutes) +
78
88
Time .hours._from (hours) +
79
89
Time .days._from (days),
80
90
precision);
81
91
92
+ /// Constructs a [Time] from a picosecond amount.
93
+ Time .ofPicoseconds (final double picoseconds,
94
+ {final Precision precision = Precision .max})
95
+ : this ._(Time .picoseconds._from (picoseconds), precision);
96
+
97
+ /// Constructs a [Time] from a nanosecond amount.
98
+ Time .ofNanoseconds (final double nanoseconds,
99
+ {final Precision precision = Precision .max})
100
+ : this ._(Time .nanoseconds._from (nanoseconds), precision);
101
+
82
102
/// Constructs a [Time] from a microsecond amount.
83
103
Time .ofMicroseconds (final double microseconds,
84
104
{final Precision precision = Precision .max})
@@ -117,6 +137,12 @@ class Time extends Measurement<Time> {
117
137
/// Note that any granularity below microseconds will be lost.
118
138
Duration get asDuration => Duration (microseconds: asMicroseconds.toInt ());
119
139
140
+ /// Interprets this as a number of microseconds.
141
+ double get asPicoseconds => _preciseOf (picoseconds);
142
+
143
+ /// Interprets this as a number of microseconds.
144
+ double get asNanoseconds => _preciseOf (nanoseconds);
145
+
120
146
/// Interprets this as a number of microseconds.
121
147
double get asMicroseconds => _preciseOf (microseconds);
122
148
0 commit comments