Skip to content

Commit

Permalink
Add example to rfc3339's docs (#391)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadlock0133 authored Nov 11, 2021
1 parent bca24a9 commit fff7f80
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/format_description/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,26 @@ mod helper {
/// Well-known formats, typically RFCs.
pub mod well_known {
/// The format described in [RFC 3339](https://tools.ietf.org/html/rfc3339#section-5.6).
///
/// Format example: 1985-04-12T23:20:50.52Z
///
/// ```rust
/// # use time::{format_description::well_known::Rfc3339, macros::datetime, OffsetDateTime};
/// assert_eq!(
/// OffsetDateTime::parse("1985-04-12T23:20:50.52Z", &Rfc3339)?,
/// datetime!(1985-04-12 23:20:50.52 +00:00)
/// );
/// # Ok::<_, time::Error>(())
/// ```
///
/// ```rust
/// # use time::{format_description::well_known::Rfc3339, macros::datetime};
/// assert_eq!(
/// datetime!(1985-04-12 23:20:50.52 +00:00).format(&Rfc3339)?,
/// "1985-04-12T23:20:50.52Z"
/// );
/// # Ok::<_, time::Error>(())
/// ```
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Rfc3339;
}
Expand Down

0 comments on commit fff7f80

Please sign in to comment.