Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for and Bump Chrono version to 0.4.10 #360

Merged
merged 2 commits into from Nov 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 18 additions & 2 deletions CHANGELOG.md
Expand Up @@ -8,13 +8,29 @@ Chrono obeys the principle of [Semantic Versioning](http://semver.org/).
There were/are numerous minor versions before 1.0 due to the language changes.
Versions with only mechanical changes will be omitted from the following list.

## next
## 0.4.10

### Improvements

* `DateTime::parse_from_str` is more than 2x faster in some cases. (@michalsrb
#358)
* Significant improvements to no-std and alloc support (This should also make
many format/serialization operations induce zero unnecessary allocations)
(@CryZe #341)

### Features

* Functions that were accepting `Iterator` of `Item`s (for example
`format_with_items`) now accept `Iterator` of `Borrow<Item>`, so one can
use values or references.
use values or references. (@michalsrb #358)
* Add built-in support for structs with nested `Option<Datetime>` etc fields
(@manifest #302)

### Internal/doc improvements

* Use markdown footnotes on the `strftime` docs page (@qudlibetor #359)
* Migrate from `try!` -> `?` (question mark) because it is now emitting
deprecation warnings and has been stable since rustc 1.13.0

## 0.4.9

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "chrono"
version = "0.4.9"
version = "0.4.10"
authors = [
"Kang Seonghoon <public+rust@mearie.org>",
"Brandon W Maister <quodlibetor@gmail.com>",
Expand Down
24 changes: 12 additions & 12 deletions src/datetime.rs
Expand Up @@ -327,7 +327,7 @@ impl DateTime<FixedOffset> {
pub fn parse_from_rfc2822(s: &str) -> ParseResult<DateTime<FixedOffset>> {
const ITEMS: &'static [Item<'static>] = &[Item::Fixed(Fixed::RFC2822)];
let mut parsed = Parsed::new();
try!(parse(&mut parsed, s, ITEMS.iter()));
parse(&mut parsed, s, ITEMS.iter())?;
parsed.to_datetime()
}

Expand All @@ -339,7 +339,7 @@ impl DateTime<FixedOffset> {
pub fn parse_from_rfc3339(s: &str) -> ParseResult<DateTime<FixedOffset>> {
const ITEMS: &'static [Item<'static>] = &[Item::Fixed(Fixed::RFC3339)];
let mut parsed = Parsed::new();
try!(parse(&mut parsed, s, ITEMS.iter()));
parse(&mut parsed, s, ITEMS.iter())?;
parsed.to_datetime()
}

Expand All @@ -365,7 +365,7 @@ impl DateTime<FixedOffset> {
/// ```
pub fn parse_from_str(s: &str, fmt: &str) -> ParseResult<DateTime<FixedOffset>> {
let mut parsed = Parsed::new();
try!(parse(&mut parsed, s, StrftimeItems::new(fmt)));
parse(&mut parsed, s, StrftimeItems::new(fmt))?;
parsed.to_datetime()
}
}
Expand Down Expand Up @@ -639,7 +639,7 @@ impl str::FromStr for DateTime<FixedOffset> {
];

let mut parsed = Parsed::new();
try!(parse(&mut parsed, s, ITEMS.iter()));
parse(&mut parsed, s, ITEMS.iter())?;
parsed.to_datetime()
}
}
Expand Down Expand Up @@ -808,7 +808,7 @@ pub mod rustc_serialize {
}
}

// try!-like function to convert a LocalResult into a serde-ish Result
// lik? function to convert a LocalResult into a serde-ish Result
fn from<T, D>(me: LocalResult<T>, d: &mut D) -> Result<T, D::Error>
where D: Decoder,
T: fmt::Display,
Expand Down Expand Up @@ -943,7 +943,7 @@ pub mod serde {
#[derive(Debug)]
pub struct MilliSecondsTimestampVisitor;

// try!-like function to convert a LocalResult into a serde-ish Result
// lik? function to convert a LocalResult into a serde-ish Result
fn serde_from<T, E, V>(me: LocalResult<T>, ts: &V) -> Result<T, E>
where
E: de::Error,
Expand Down Expand Up @@ -1073,7 +1073,7 @@ pub mod serde {
pub fn deserialize<'de, D>(d: D) -> Result<DateTime<Utc>, D::Error>
where D: de::Deserializer<'de>
{
Ok(try!(d.deserialize_i64(NanoSecondsTimestampVisitor)))
Ok(d.deserialize_i64(NanoSecondsTimestampVisitor)?)
}

impl<'de> de::Visitor<'de> for NanoSecondsTimestampVisitor {
Expand Down Expand Up @@ -1220,7 +1220,7 @@ pub mod serde {
pub fn deserialize<'de, D>(d: D) -> Result<Option<DateTime<Utc>>, D::Error>
where D: de::Deserializer<'de>
{
Ok(try!(d.deserialize_option(OptionNanoSecondsTimestampVisitor)))
Ok(d.deserialize_option(OptionNanoSecondsTimestampVisitor)?)
}

struct OptionNanoSecondsTimestampVisitor;
Expand Down Expand Up @@ -1364,7 +1364,7 @@ pub mod serde {
pub fn deserialize<'de, D>(d: D) -> Result<DateTime<Utc>, D::Error>
where D: de::Deserializer<'de>
{
Ok(try!(d.deserialize_i64(MilliSecondsTimestampVisitor).map(|dt| dt.with_timezone(&Utc))))
Ok(d.deserialize_i64(MilliSecondsTimestampVisitor).map(|dt| dt.with_timezone(&Utc))?)
}

impl<'de> de::Visitor<'de> for MilliSecondsTimestampVisitor {
Expand Down Expand Up @@ -1511,7 +1511,7 @@ pub mod serde {
pub fn deserialize<'de, D>(d: D) -> Result<Option<DateTime<Utc>>, D::Error>
where D: de::Deserializer<'de>
{
Ok(try!(d.deserialize_option(OptionMilliSecondsTimestampVisitor).map(|opt| opt.map(|dt| dt.with_timezone(&Utc)))))
Ok(d.deserialize_option(OptionMilliSecondsTimestampVisitor).map(|opt| opt.map(|dt| dt.with_timezone(&Utc)))?)
}

struct OptionMilliSecondsTimestampVisitor;
Expand Down Expand Up @@ -1655,7 +1655,7 @@ pub mod serde {
pub fn deserialize<'de, D>(d: D) -> Result<DateTime<Utc>, D::Error>
where D: de::Deserializer<'de>
{
Ok(try!(d.deserialize_i64(SecondsTimestampVisitor)))
Ok(d.deserialize_i64(SecondsTimestampVisitor)?)
}

impl<'de> de::Visitor<'de> for SecondsTimestampVisitor {
Expand Down Expand Up @@ -1798,7 +1798,7 @@ pub mod serde {
pub fn deserialize<'de, D>(d: D) -> Result<Option<DateTime<Utc>>, D::Error>
where D: de::Deserializer<'de>
{
Ok(try!(d.deserialize_option(OptionSecondsTimestampVisitor)))
Ok(d.deserialize_option(OptionSecondsTimestampVisitor)?)
}

struct OptionSecondsTimestampVisitor;
Expand Down
36 changes: 17 additions & 19 deletions src/format/mod.rs
Expand Up @@ -433,22 +433,20 @@ pub fn format<'a, I, B>(


if let Some(v) = v {
try!(
if (spec == &Year || spec == &IsoYear) && !(0 <= v && v < 10_000) {
// non-four-digit years require an explicit sign as per ISO 8601
match pad {
&Pad::None => write!(result, "{:+}", v),
&Pad::Zero => write!(result, "{:+01$}", v, width + 1),
&Pad::Space => write!(result, "{:+1$}", v, width + 1),
}
} else {
match pad {
&Pad::None => write!(result, "{}", v),
&Pad::Zero => write!(result, "{:01$}", v, width),
&Pad::Space => write!(result, "{:1$}", v, width),
}
if (spec == &Year || spec == &IsoYear) && !(0 <= v && v < 10_000) {
// non-four-digit years require an explicit sign as per ISO 8601
match pad {
&Pad::None => write!(result, "{:+}", v),
&Pad::Zero => write!(result, "{:+01$}", v, width + 1),
&Pad::Space => write!(result, "{:+1$}", v, width + 1),
}
} else {
match pad {
&Pad::None => write!(result, "{}", v),
&Pad::Zero => write!(result, "{:01$}", v, width),
&Pad::Space => write!(result, "{:1$}", v, width),
}
)
}?
} else {
return Err(fmt::Error) // insufficient arguments for given format
}
Expand Down Expand Up @@ -575,13 +573,13 @@ pub fn format<'a, I, B>(
&RFC2822 => // same to `%a, %e %b %Y %H:%M:%S %z`
if let (Some(d), Some(t), Some(&(_, off))) = (date, time, off) {
let sec = t.second() + t.nanosecond() / 1_000_000_000;
try!(write!(
write!(
result,
"{}, {:02} {} {:04} {:02}:{:02}:{:02} ",
SHORT_WEEKDAYS[d.weekday().num_days_from_monday() as usize],
d.day(), SHORT_MONTHS[d.month0() as usize], d.year(),
t.hour(), t.minute(), sec
));
)?;
Some(write_local_minus_utc(&mut result, off, false, false))
} else {
None
Expand All @@ -590,15 +588,15 @@ pub fn format<'a, I, B>(
if let (Some(d), Some(t), Some(&(_, off))) = (date, time, off) {
// reuse `Debug` impls which already print ISO 8601 format.
// this is faster in this way.
try!(write!(result, "{:?}T{:?}", d, t));
write!(result, "{:?}T{:?}", d, t)?;
Some(write_local_minus_utc(&mut result, off, false, true))
} else {
None
},
};

match ret {
Some(ret) => try!(ret),
Some(ret) => ret?,
None => return Err(fmt::Error), // insufficient arguments for given format
}
},
Expand Down