File tree Expand file tree Collapse file tree 3 files changed +7
-9
lines changed
Expand file tree Collapse file tree 3 files changed +7
-9
lines changed Original file line number Diff line number Diff line change 11[package ]
22name = " httpdate"
3- version = " 1.0.0 "
3+ version = " 1.0.1 "
44authors = [
" Pyfisch <[email protected] >" ]
55license = " MIT/Apache-2.0"
66description = " HTTP date parsing and formatting"
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ impl HttpDate {
4141 && self . mon <= 12
4242 && self . year >= 1970
4343 && self . year <= 9999
44+ && & HttpDate :: from ( SystemTime :: from ( * self ) ) == self
4445 }
4546}
4647
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ pub fn fmt_http_date(d: SystemTime) -> String {
6363#[ cfg( test) ]
6464mod tests {
6565 use std:: str;
66- use std:: time:: { Duration , SystemTime , UNIX_EPOCH } ;
66+ use std:: time:: { Duration , UNIX_EPOCH } ;
6767
6868 use super :: { fmt_http_date, parse_http_date, HttpDate } ;
6969
@@ -151,12 +151,9 @@ mod tests {
151151 }
152152
153153 #[ test]
154- fn test_date_equality ( ) {
155- let nov_07_sys = UNIX_EPOCH + Duration :: new ( 784198117 , 0 ) ;
156- let nov_07 = nov_07_sys. into ( ) ;
157- let parsed = "Sun, 07 Nov 1994 08:48:37 GMT" . parse :: < HttpDate > ( ) . unwrap ( ) ;
158- let parsed_sys: SystemTime = parsed. into ( ) ;
159- assert_eq ! ( parsed_sys, nov_07_sys) ;
160- assert_eq ! ( parsed, nov_07) ;
154+ fn test_parse_bad_date ( ) {
155+ // 1994-11-07 is actually a Monday
156+ let parsed = "Sun, 07 Nov 1994 08:48:37 GMT" . parse :: < HttpDate > ( ) ;
157+ assert ! ( parsed. is_err( ) )
161158 }
162159}
You can’t perform that action at this time.
0 commit comments