File tree 1 file changed +8
-3
lines changed
1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -208,9 +208,14 @@ pub struct NaiveTime {
208
208
#[ cfg( feature = "arbitrary" ) ]
209
209
impl arbitrary:: Arbitrary < ' _ > for NaiveTime {
210
210
fn arbitrary ( u : & mut arbitrary:: Unstructured ) -> arbitrary:: Result < NaiveTime > {
211
- let secs = u. int_in_range ( 0 ..=86_399 ) ?;
212
- let nano = u. int_in_range ( 0 ..=1_999_999_999 ) ?;
213
- let time = NaiveTime :: from_num_seconds_from_midnight_opt ( secs, nano)
211
+ let mins = u. int_in_range ( 0 ..=1439 ) ?;
212
+ let mut secs = u. int_in_range ( 0 ..=60 ) ?;
213
+ let mut nano = u. int_in_range ( 0 ..=999_999_999 ) ?;
214
+ if secs == 60 {
215
+ secs = 59 ;
216
+ nano += 1_000_000_000 ;
217
+ }
218
+ let time = NaiveTime :: from_num_seconds_from_midnight_opt ( mins * 60 + secs, nano)
214
219
. expect ( "Could not generate a valid chrono::NaiveTime. It looks like implementation of Arbitrary for NaiveTime is erroneous." ) ;
215
220
Ok ( time)
216
221
}
You can’t perform that action at this time.
0 commit comments