Skip to content

Commit

Permalink
Merge pull request #228 from quodlibetor/0.4.1-release
Browse files Browse the repository at this point in the history
0.4.1 release
  • Loading branch information
quodlibetor authored Mar 28, 2018
2 parents c9609ea + 1ddc67c commit ee52f2f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
26 changes: 24 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,32 @@ 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 mechnical changes will be omitted from the following list.

## 0.4.1

### Bug Fixes

* Allow parsing timestamps with subsecond precision (@jonasbb)
* RFC2822 allows times to not include the second (@upsuper)

### Features

* New `timestamp_millis` method on `DateTime` and `NaiveDateTim` that returns
number of milliseconds since the epoch. (@quodlibetor)
* Support exact decimal width on subsecond display for RFC3339 via a new
`to_rfc3339_opts` method on `DateTime` (@dekellum)
* Use no_std-compatible num dependencies (@cuviper)
* Add `SubsecRound` trait that allows rounding to the nearest second
(@dekellum)

### Code Hygiene and Docs

* Docs! (@alatiera @kosta @quodlibetor @kennytm)
* Run clippy and various fixes (@quodlibetor)

## 0.4.0 (2017-06-22)

This was originally planned as a minor release but was pushed to a major release
due to the compatibility concern raised.
This was originally planned as a minor release but was pushed to a major
release due to the compatibility concern raised.

### Added

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "chrono"
version = "0.4.0"
version = "0.4.1"
authors = ["Kang Seonghoon <[email protected]>"]

description = "Date and time library for Rust"
Expand Down
17 changes: 17 additions & 0 deletions src/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ use format::{parse, Parsed, ParseError, ParseResult, DelayedFormat, StrftimeItem

/// Specific formatting options for seconds. This may be extended in the
/// future, so exhaustive matching in external code is not recommended.
///
/// See the `TimeZone::to_rfc3339_opts` function for usage.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum SecondsFormat {
/// Format whole seconds only, with no decimal point nor subseconds.
Expand All @@ -39,6 +41,10 @@ pub enum SecondsFormat {
/// display all available non-zero sub-second digits. This corresponds to
/// [Fixed::Nanosecond](format/enum.Fixed.html#variant.Nanosecond).
AutoSi,

// Do not match against this.
#[doc(hidden)]
__NonExhaustive,
}

/// ISO 8601 combined date and time with time zone.
Expand Down Expand Up @@ -300,6 +306,8 @@ impl<Tz: TimeZone> DateTime<Tz> where Tz::Offset: fmt::Display {
use format::Pad::Zero;
use SecondsFormat::*;

debug_assert!(secform != __NonExhaustive, "Do not use __NonExhaustive!");

const PREFIX: &'static [Item<'static>] = &[
Item::Numeric(Year, Zero),
Item::Literal("-"),
Expand All @@ -320,6 +328,7 @@ impl<Tz: TimeZone> DateTime<Tz> where Tz::Offset: fmt::Display {
Micros => Some(Item::Fixed(Fixed::Nanosecond6)),
Nanos => Some(Item::Fixed(Fixed::Nanosecond9)),
AutoSi => Some(Item::Fixed(Fixed::Nanosecond)),
__NonExhaustive => unreachable!(),
};

let tzitem = Item::Fixed(
Expand Down Expand Up @@ -1177,6 +1186,14 @@ mod tests {
assert_eq!(ut.to_rfc3339_opts(AutoSi, true), "2018-01-11T02:05:13.084660Z");
}

#[test]
#[should_panic]
fn test_rfc3339_opts_nonexhaustive() {
use SecondsFormat;
let dt = Utc.ymd(1999, 10, 9).and_hms(1, 2, 3);
dt.to_rfc3339_opts(SecondsFormat::__NonExhaustive, true);
}

#[test]
fn test_datetime_from_str() {
assert_eq!("2015-2-18T23:16:9.15Z".parse::<DateTime<FixedOffset>>(),
Expand Down

0 comments on commit ee52f2f

Please sign in to comment.