File tree 4 files changed +22
-5
lines changed 4 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,12 @@ Versioning].
7
7
8
8
---
9
9
10
+ ## 0.2.25 [ 2021-01-24]
11
+
12
+ ### Fixed
13
+
14
+ - Fix #309 , which can cause panics in certain situations.
15
+
10
16
## 0.2.24 [ 2021-01-08]
11
17
12
18
### Fixed
Original file line number Diff line number Diff line change 1
1
[package ]
2
2
name = " time"
3
- version = " 0.2.24 "
3
+ version = " 0.2.25 "
4
4
authors = [
" Jacob Pratt <[email protected] >" ]
5
5
edition = " 2018"
6
6
repository = " https://github.com/time-rs/time"
Original file line number Diff line number Diff line change @@ -542,11 +542,11 @@ impl Date {
542
542
} ;
543
543
544
544
let raw_weekday =
545
- ( day as i32 + ( 13 * ( month as i32 + 1 ) ) / 5 + adjusted_year + adjusted_year / 4
545
+ ( ( day as i32 + ( 13 * ( month as i32 + 1 ) ) / 5 + adjusted_year + adjusted_year / 4
546
546
- adjusted_year / 100
547
547
+ adjusted_year / 400 )
548
- % 7
549
- - 2 ;
548
+ - 2 )
549
+ % 7 ;
550
550
551
551
if raw_weekday < 0 {
552
552
( raw_weekday + 7 ) as u8
@@ -586,7 +586,7 @@ impl Date {
586
586
6 => Weekday :: Sunday ,
587
587
// FIXME The compiler isn't able to optimize this away. See
588
588
// rust-lang/rust#66993.
589
- _ => unreachable ! ( "A value mod 7 is always in the range 0..7" ) ,
589
+ n => unreachable ! ( "A value mod 7 is always in the range 0..7 (was {})" , n ) ,
590
590
}
591
591
}
592
592
Original file line number Diff line number Diff line change @@ -1230,3 +1230,14 @@ fn previous_day_panics() {
1230
1230
fn julian_day_panics ( ) {
1231
1231
Date :: from_julian_day ( i64:: MAX ) ;
1232
1232
}
1233
+
1234
+ #[ test]
1235
+ fn issue_309 ( ) {
1236
+ assert_eq ! ( date!( -36 - 11 - 01 ) . weekday( ) , Weekday :: Sunday ) ;
1237
+ assert_eq ! ( date!( -26 - 96 ) . weekday( ) , Weekday :: Sunday ) ;
1238
+ assert_eq ! ( date!( -31 - 137 ) . weekday( ) , Weekday :: Sunday ) ;
1239
+ assert_eq ! ( date!( -31 - 137 ) . week( ) , 20 ) ;
1240
+ assert_eq ! ( date!( -60 - 63 ) . iso_year_week( ) , ( -60 , 9 ) ) ;
1241
+ assert_eq ! ( date!( -208 - 99 ) . week( ) , 14 ) ;
1242
+ assert_eq ! ( util:: weeks_in_year( -102 ) , 52 ) ;
1243
+ }
You can’t perform that action at this time.
0 commit comments