1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-12-18 01:43:58 +01:00

Merge pull request #1372 from JohnTitor/time-0.2.7

Update `time` to 0.2.7
This commit is contained in:
Yuki Okushi 2020-02-25 06:58:33 +09:00 committed by GitHub
commit 1249262c35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 19 additions and 19 deletions

View File

@ -9,7 +9,7 @@
* Skip empty chunks when returning response from a `Stream` #1308 * Skip empty chunks when returning response from a `Stream` #1308
* Update the `time` dependency to 0.2.5 * Update the `time` dependency to 0.2.7
## [2.0.0] - 2019-12-25 ## [2.0.0] - 2019-12-25

View File

@ -87,7 +87,7 @@ regex = "1.3"
serde = { version = "1.0", features=["derive"] } serde = { version = "1.0", features=["derive"] }
serde_json = "1.0" serde_json = "1.0"
serde_urlencoded = "0.6.1" serde_urlencoded = "0.6.1"
time = { version = "0.2.5", default-features = false, features = ["std"] } time = { version = "0.2.7", default-features = false, features = ["std"] }
url = "2.1" url = "2.1"
open-ssl = { version="0.10", package = "openssl", optional = true } open-ssl = { version="0.10", package = "openssl", optional = true }
rust-tls = { version = "0.16.0", package = "rustls", optional = true } rust-tls = { version = "0.16.0", package = "rustls", optional = true }

View File

@ -4,7 +4,7 @@
### Changed ### Changed
* Update the `time` dependency to 0.2.5 * Update the `time` dependency to 0.2.7
### Fixed ### Fixed

View File

@ -76,7 +76,7 @@ serde_json = "1.0"
sha-1 = "0.8" sha-1 = "0.8"
slab = "0.4" slab = "0.4"
serde_urlencoded = "0.6.1" serde_urlencoded = "0.6.1"
time = { version = "0.2.5", default-features = false, features = ["std"] } time = { version = "0.2.7", default-features = false, features = ["std"] }
# for secure cookie # for secure cookie
ring = { version = "0.16.9", optional = true } ring = { version = "0.16.9", optional = true }

View File

@ -990,7 +990,7 @@ impl<'a, 'b> PartialEq<Cookie<'b>> for Cookie<'a> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::{Cookie, SameSite}; use super::{Cookie, SameSite};
use time::{offset, PrimitiveDateTime}; use time::PrimitiveDateTime;
#[test] #[test]
fn format() { fn format() {
@ -1015,7 +1015,7 @@ mod tests {
assert_eq!(&cookie.to_string(), "foo=bar; Domain=www.rust-lang.org"); assert_eq!(&cookie.to_string(), "foo=bar; Domain=www.rust-lang.org");
let time_str = "Wed, 21 Oct 2015 07:28:00 GMT"; let time_str = "Wed, 21 Oct 2015 07:28:00 GMT";
let expires = PrimitiveDateTime::parse(time_str, "%a, %d %b %Y %H:%M:%S").unwrap().using_offset(offset!(UTC)); let expires = PrimitiveDateTime::parse(time_str, "%a, %d %b %Y %H:%M:%S").unwrap().assume_utc();
let cookie = Cookie::build("foo", "bar").expires(expires).finish(); let cookie = Cookie::build("foo", "bar").expires(expires).finish();
assert_eq!( assert_eq!(
&cookie.to_string(), &cookie.to_string(),

View File

@ -6,7 +6,7 @@ use std::fmt;
use std::str::Utf8Error; use std::str::Utf8Error;
use percent_encoding::percent_decode; use percent_encoding::percent_decode;
use time::{Duration, offset}; use time::Duration;
use super::{Cookie, CookieStr, SameSite}; use super::{Cookie, CookieStr, SameSite};
@ -188,7 +188,7 @@ fn parse_inner<'c>(s: &str, decode: bool) -> Result<Cookie<'c>, ParseError> {
.or_else(|| time::parse(v, "%a, %d-%b-%Y %H:%M:%S").ok()); .or_else(|| time::parse(v, "%a, %d-%b-%Y %H:%M:%S").ok());
if let Some(time) = tm { if let Some(time) = tm {
cookie.expires = Some(time.using_offset(offset!(UTC))) cookie.expires = Some(time.assume_utc())
} }
} }
_ => { _ => {
@ -216,7 +216,7 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::{Cookie, SameSite}; use super::{Cookie, SameSite};
use time::{offset, Duration, PrimitiveDateTime}; use time::{Duration, PrimitiveDateTime};
macro_rules! assert_eq_parse { macro_rules! assert_eq_parse {
($string:expr, $expected:expr) => { ($string:expr, $expected:expr) => {
@ -376,7 +376,7 @@ mod tests {
); );
let time_str = "Wed, 21 Oct 2015 07:28:00 GMT"; let time_str = "Wed, 21 Oct 2015 07:28:00 GMT";
let expires = PrimitiveDateTime::parse(time_str, "%a, %d %b %Y %H:%M:%S").unwrap().using_offset(offset!(UTC)); let expires = PrimitiveDateTime::parse(time_str, "%a, %d %b %Y %H:%M:%S").unwrap().assume_utc();
expected.set_expires(expires); expected.set_expires(expires);
assert_eq_parse!( assert_eq_parse!(
" foo=bar ;HttpOnly; Secure; Max-Age=4; Path=/foo; \ " foo=bar ;HttpOnly; Secure; Max-Age=4; Path=/foo; \
@ -385,7 +385,7 @@ mod tests {
); );
unexpected.set_domain("foo.com"); unexpected.set_domain("foo.com");
let bad_expires = PrimitiveDateTime::parse(time_str, "%a, %d %b %Y %H:%S:%M").unwrap().using_offset(offset!(UTC)); let bad_expires = PrimitiveDateTime::parse(time_str, "%a, %d %b %Y %H:%S:%M").unwrap().assume_utc();
expected.set_expires(bad_expires); expected.set_expires(bad_expires);
assert_ne_parse!( assert_ne_parse!(
" foo=bar ;HttpOnly; Secure; Max-Age=4; Path=/foo; \ " foo=bar ;HttpOnly; Secure; Max-Age=4; Path=/foo; \

View File

@ -20,7 +20,7 @@ impl FromStr for HttpDate {
fn from_str(s: &str) -> Result<HttpDate, ParseError> { fn from_str(s: &str) -> Result<HttpDate, ParseError> {
match time_parser::parse_http_date(s) { match time_parser::parse_http_date(s) {
Some(t) => Ok(HttpDate(t.using_offset(offset!(UTC)))), Some(t) => Ok(HttpDate(t.assume_utc())),
None => Err(ParseError::Header) None => Err(ParseError::Header)
} }
} }
@ -40,7 +40,7 @@ impl From<OffsetDateTime> for HttpDate {
impl From<SystemTime> for HttpDate { impl From<SystemTime> for HttpDate {
fn from(sys: SystemTime) -> HttpDate { fn from(sys: SystemTime) -> HttpDate {
HttpDate(PrimitiveDateTime::from(sys).using_offset(offset!(UTC))) HttpDate(PrimitiveDateTime::from(sys).assume_utc())
} }
} }
@ -66,14 +66,14 @@ impl From<HttpDate> for SystemTime {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::HttpDate; use super::HttpDate;
use time::{PrimitiveDateTime, date, time, offset}; use time::{PrimitiveDateTime, date, time};
#[test] #[test]
fn test_date() { fn test_date() {
let nov_07 = HttpDate(PrimitiveDateTime::new( let nov_07 = HttpDate(PrimitiveDateTime::new(
date!(1994-11-07), date!(1994-11-07),
time!(8:48:37) time!(8:48:37)
).using_offset(offset!(UTC))); ).assume_utc());
assert_eq!( assert_eq!(
"Sun, 07 Nov 1994 08:48:37 GMT".parse::<HttpDate>().unwrap(), "Sun, 07 Nov 1994 08:48:37 GMT".parse::<HttpDate>().unwrap(),

View File

@ -1,4 +1,4 @@
use time::{PrimitiveDateTime, Date}; use time::{OffsetDateTime, PrimitiveDateTime, Date};
/// Attempt to parse a `time` string as one of either RFC 1123, RFC 850, or asctime. /// Attempt to parse a `time` string as one of either RFC 1123, RFC 850, or asctime.
pub fn parse_http_date(time: &str) -> Option<PrimitiveDateTime> { pub fn parse_http_date(time: &str) -> Option<PrimitiveDateTime> {
@ -19,7 +19,7 @@ fn try_parse_rfc_850(time: &str) -> Option<PrimitiveDateTime> {
// If the `time` string contains a two-digit year, then as per RFC 2616 § 19.3, // If the `time` string contains a two-digit year, then as per RFC 2616 § 19.3,
// we consider the year as part of this century if it's within the next 50 years, // we consider the year as part of this century if it's within the next 50 years,
// otherwise we consider as part of the previous century. // otherwise we consider as part of the previous century.
let now = PrimitiveDateTime::now(); let now = OffsetDateTime::now();
let century_start_year = (now.year() / 100) * 100; let century_start_year = (now.year() / 100) * 100;
let mut expanded_year = century_start_year + dt.year(); let mut expanded_year = century_start_year + dt.year();

View File

@ -2,7 +2,7 @@
## [Unreleased] - 2020-xx-xx ## [Unreleased] - 2020-xx-xx
* Update the `time` dependency to 0.2.5 * Update the `time` dependency to 0.2.7
## [1.0.0] - 2019-12-13 ## [1.0.0] - 2019-12-13

View File

@ -51,7 +51,7 @@ serde_json = "1.0"
sha1 = "0.6" sha1 = "0.6"
slab = "0.4" slab = "0.4"
serde_urlencoded = "0.6.1" serde_urlencoded = "0.6.1"
time = { version = "0.2.5", default-features = false, features = ["std"] } time = { version = "0.2.7", default-features = false, features = ["std"] }
open-ssl = { version="0.10", package="openssl", optional = true } open-ssl = { version="0.10", package="openssl", optional = true }
[dev-dependencies] [dev-dependencies]