Sys/Time/Util.pm untested

filter: Statementstmt n/a Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a SCAR -
1 package SPVM::Sys::Time::Util;
2  
3  
4  
5 1;
6  
7 =head1 Name
8  
9 SPVM::Sys::Time::Util - Time Utilities
10  
11 =head1 Description
12  
13 Sys::Time::Util class in L<SPVM> has utility methods to manipulate time.
14  
15 =head1 Usage
16  
17 use Sys::Time::Util;
18  
19 =head1 Class Methods
20  
21 =head2 nanoseconds_to_timespec
22  
23 C<static method nanoseconds_to_timespec : L<Sys::Time::Timespec|SPVM::Sys::Time::Timespec> ($nanoseconds : long);>
24  
25 Converts nanoseconds $nanoseconds to a L<Sys::Time::Timespec|SPVM::Sys::Time::Timespec> object, and returns it.
26  
27 Exceptions:
28  
29 $nanoseconds must be greater than or equal to 0. Otherwise an exception is thrown.
30  
31 =head2 timespec_to_nanoseconds
32  
33 C<static method timespec_to_nanoseconds : long ($ts : L<Sys::Time::Timespec|SPVM::Sys::Time::Timespec>);>
34  
35 Converts the L<Sys::Time::Timespec|SPVM::Sys::Time::Timespec> object $ts to nanoseconds, and returns it.
36  
37 This method could cause overflow.
38  
39 Exceptions:
40  
41 $ts must be defined. Otherwise an exception is thrown.
42  
43 $ts->tv_sec must be greater than or equal to 0. Otherwise an exception is thrown.
44  
45 $ts->tv_nsec must be greater than or equal to 0. Otherwise an exception is thrown.
46  
47 =head2 microseconds_to_timeval
48  
49 C<static method microseconds_to_timeval : L<Sys::Time::Timeval|SPVM::Sys::Time::Timeval> ($microseconds : long);>
50  
51 Converts microseconds $microseconds to a L<Sys::Time::Timeval|SPVM::Sys::Time::Timeval> object, and returns it.
52  
53 Exceptions:
54  
55 $microseconds must be greater than or equal to 0. Otherwise an exception is thrown.
56  
57 =head2 timeval_to_microseconds
58  
59 C<static method timeval_to_microseconds : double ($tv : L<Sys::Time::Timeval|SPVM::Sys::Time::Timeval>);>
60  
61 Converts the L<Sys::Time::Timeval|SPVM::Sys::Time::Timeval> object $tv to microseconds, and returns it.
62  
63 This method could cause overflow.
64  
65 Exceptions:
66  
67 $tv must be defined. Otherwise an exception is thrown.
68  
69 $tv->tv_sec must be greater than or equal to 0. Otherwise an exception is thrown.
70  
71 $tv->tv_usec must be greater than or equal to 0. Otherwise an exception is thrown.
72  
73 =head2 float_seconds_to_timespec
74  
75 C<static method float_seconds_to_timespec : L<Sys::Time::Timespec|SPVM::Sys::Time::Timespec> ($float_seconds : double);>
76  
77 Converts floating seconds $float_seconds to a L<Sys::Time::Timespec|SPVM::Sys::Time::Timespec> object, and returns it.
78  
79 This method may result in a loss of precision.
80  
81 Exceptions:
82  
83 $float_seconds must be greater than or equal to 0. Otherwise an exception is thrown.
84  
85 =head2 timespec_to_float_seconds
86  
87 C<static method timespec_to_float_seconds : double ($ts : L<Sys::Time::Timespec|SPVM::Sys::Time::Timespec>);>
88  
89 Converts the L<Sys::Time::Timespec|SPVM::Sys::Time::Timespec> object $ts to floating seconds, and returns it.
90  
91 This method may result in a loss of precision.
92  
93 Exceptions:
94  
95 $ts must be defined. Otherwise an exception is thrown.
96  
97 $ts->tv_sec must be greater than or equal to 0. Otherwise an exception is thrown.
98  
99 $ts->tv_nsec must be greater than or equal to 0. Otherwise an exception is thrown.
100  
101 =head2 float_seconds_to_timeval
102  
103 C<static method float_seconds_to_timeval : L<Sys::Time::Timeval|SPVM::Sys::Time::Timeval> ($float_seconds : double);>
104  
105 Converts floating seconds $float_seconds to a L<Sys::Time::Timeval|SPVM::Sys::Time::Timeval> object, and returns it.
106  
107 This method may result in a loss of precision.
108  
109 Exceptions:
110  
111 $float_seconds must be greater than or equal to 0. Otherwise an exception is thrown.
112  
113 =head2 timeval_to_float_seconds
114  
115 C<static method timeval_to_float_seconds : double ($tv : L<Sys::Time::Timeval|SPVM::Sys::Time::Timeval>);>
116  
117 Converts the L<Sys::Time::Timeval|SPVM::Sys::Time::Timeval> object $tv to floating seconds, and returns it.
118  
119 This method may result in a loss of precision.
120  
121 Exceptions:
122  
123 $tv must be defined. Otherwise an exception is thrown.
124  
125 $tv->tv_sec must be greater than or equal to 0. Otherwise an exception is thrown.
126  
127 $tv->tv_usec must be greater than or equal to 0. Otherwise an exception is thrown.
128
129 =head2 float_seconds_to_nanoseconds
130  
131 C<static method float_seconds_to_nanoseconds : long ($float_seconds : double);>
132  
133 Converts floating seconds $float_seconds to nanoseconds, and returns it.
134  
135 This method may result in a loss of precision.
136  
137 Excetpions:
138  
139 $float_seconds must be greater than or equal to 0. Otherwise an exception is thrown.
140  
141 =head2 nanoseconds_to_float_seconds
142  
143 C<static method nanoseconds_to_float_seconds : double ($nanoseconds : long);>
144  
145 Converts nanoseconds $nanoseconds to floating seconds, and returns it.
146  
147 This method may result in a loss of precision.
148  
149 Excetpions:
150  
151 $nanoseconds must be greater than or equal to 0. Otherwise an exception is thrown.
152  
153 =head2 float_seconds_to_microseconds
154  
155 C<static method float_seconds_to_microseconds : long ($float_seconds : double);>
156  
157 Converts floating seconds $float_seconds to microseconds, and returns it.
158  
159 This method may result in a loss of precision.
160  
161 Excetpions:
162  
163 $float_seconds must be greater than or equal to 0. Otherwise an exception is thrown.
164  
165 =head2 microseconds_to_float_seconds
166  
167 C<static method microseconds_to_float_seconds : double ($microseconds : long);>
168  
169 Converts microseconds $microseconds to floating seconds, and returns it.
170  
171 This method may result in a loss of precision.
172  
173 Excetpions:
174  
175 $float_seconds must be greater than or equal to 0. Otherwise an exception is thrown.
176  
177 =head2 timeval_interval
178  
179 C<static method timeval_interval : double ($tv_a : L<Sys::Time::Timeval|SPVM::Sys::Time::Timeval>, $tv_b : L<Sys::Time::Timeval|SPVM::Sys::Time::Timeval>);>
180  
181 Calculates $tv_b minus $tv_a and returns it as floating seconds.
182  
183 This method may result in a loss of precision.
184  
185 Excetpions:
186  
187 $tv_a must be defined. Otherwise an exception is thrown.
188  
189 $tv_b must be defined. Otherwise an exception is thrown.
190  
191 =head2 timespec_interval
192  
193 C<static method timespec_interval : double ($ts_a : L<Sys::Time::Timespec|SPVM::Sys::Time::Timespec>, $ts_b : L<Sys::Time::Timespec|SPVM::Sys::Time::Timespec>);>
194  
195 Calculates $ts_b minus $ts_a and returns it as floating seconds.
196  
197 This method may result in a loss of precision.
198  
199 Excetpions:
200  
201 $ts_a must be defined. Otherwise an exception is thrown.
202  
203 $ts_b must be defined. Otherwise an exception is thrown.
204  
205 =head2 add_timespec
206  
207 C<static method add_timespec : Sys::Time::Timespec ($ts : L<Sys::Time::Timespec|SPVM::Sys::Time::Timespec>, $diff_ts : L<Sys::Time::Timespec|SPVM::Sys::Time::Timespec>);>
208  
209 Returns $ts plus $diff_ts.
210  
211 Excetpions:
212  
213 $ts must be defined. Otherwise an exception is thrown.
214  
215 $diff_ts must be defined. Otherwise an exception is thrown.
216  
217 =head2 add_timeval
218  
219 C<static method add_timeval : Sys::Time::Timeval ($tv : L<Sys::Time::Timeval|SPVM::Sys::Time::Timeval>, $diff_tv : L<Sys::Time::Timeval|SPVM::Sys::Time::Timeval>);>
220  
221 Returns $tv plus $diff_tv.
222  
223 Excetpions:
224  
225 $tv must be defined. Otherwise an exception is thrown.
226  
227 $diff_tv must be defined. Otherwise an exception is thrown.
228  
229 =head2 subtract_timespec
230  
231 C<static method subtract_timespec : Sys::Time::Timespec ($ts : L<Sys::Time::Timespec|SPVM::Sys::Time::Timespec>, $diff_ts : L<Sys::Time::Timespec|SPVM::Sys::Time::Timespec>);>
232  
233 Returns $ts minus $diff_ts.
234  
235 Excetpions:
236  
237 $ts must be defined. Otherwise an exception is thrown.
238  
239 $diff_ts must be defined. Otherwise an exception is thrown.
240  
241 =head2 subtract_timeval
242  
243 C<static method subtract_timeval : Sys::Time::Timeval ($tv : L<Sys::Time::Timeval|SPVM::Sys::Time::Timeval>, $diff_tv : L<Sys::Time::Timeval|SPVM::Sys::Time::Timeval>);>
244  
245 Returns $tv minus $diff_tv.
246  
247 Excetpions:
248  
249 $tv must be defined. Otherwise an exception is thrown.
250  
251 $diff_tv must be defined. Otherwise an exception is thrown.
252  
253 =head1 See Also
254  
255 =over 2
256  
257 =item * L<Sys|SPVM::Sys>
258  
259 =back
260  
261 =head1 Copyright & License
262  
263 Copyright (c) 2023 Yuki Kimoto
264  
265 MIT License
266