1
0
Fork 0
mirror of https://github.com/sile/hls_m3u8.git synced 2024-06-10 01:09:27 +00:00

Remove chrono for supporting wasm32-unknown-unknown compilation target

This commit is contained in:
Takeru Ohta 2018-02-15 21:01:38 +09:00
parent 63862078db
commit 2effe63f4d
4 changed files with 16 additions and 35 deletions

View file

@ -14,7 +14,6 @@ travis-ci = {repository = "sile/hls_m3u8"}
codecov = {repository = "sile/hls_m3u8"} codecov = {repository = "sile/hls_m3u8"}
[dependencies] [dependencies]
chrono = "0.4"
trackable = "0.2" trackable = "0.2"
[dev-dependencies] [dev-dependencies]

View file

@ -22,7 +22,6 @@
//! ``` //! ```
#![warn(missing_docs)] #![warn(missing_docs)]
#![cfg_attr(feature = "cargo-clippy", allow(const_static_lifetime))] #![cfg_attr(feature = "cargo-clippy", allow(const_static_lifetime))]
extern crate chrono;
#[macro_use] #[macro_use]
extern crate trackable; extern crate trackable;

View file

@ -139,8 +139,8 @@ impl MediaSegment {
} }
/// Returns the `EXT-X-PROGRAM-DATE-TIME` tag associated with the media segment. /// Returns the `EXT-X-PROGRAM-DATE-TIME` tag associated with the media segment.
pub fn program_date_time_tag(&self) -> Option<ExtXProgramDateTime> { pub fn program_date_time_tag(&self) -> Option<&ExtXProgramDateTime> {
self.program_date_time_tag self.program_date_time_tag.as_ref()
} }
/// Returns the `EXT-X-MAP` tag associated with the media segment. /// Returns the `EXT-X-MAP` tag associated with the media segment.

View file

@ -2,7 +2,6 @@ use std::collections::BTreeMap;
use std::fmt; use std::fmt;
use std::str::FromStr; use std::str::FromStr;
use std::time::Duration; use std::time::Duration;
use chrono::{DateTime, FixedOffset, NaiveDate};
use trackable::error::ErrorKindExt; use trackable::error::ErrorKindExt;
use {Error, ErrorKind, Result}; use {Error, ErrorKind, Result};
@ -298,21 +297,21 @@ impl FromStr for ExtXMap {
/// [4.3.2.6. EXT-X-PROGRAM-DATE-TIME] /// [4.3.2.6. EXT-X-PROGRAM-DATE-TIME]
/// ///
/// [4.3.2.6. EXT-X-PROGRAM-DATE-TIME]: https://tools.ietf.org/html/rfc8216#section-4.3.2.6 /// [4.3.2.6. EXT-X-PROGRAM-DATE-TIME]: https://tools.ietf.org/html/rfc8216#section-4.3.2.6
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ExtXProgramDateTime { pub struct ExtXProgramDateTime {
date_time: DateTime<FixedOffset>, date_time: SingleLineString,
} }
impl ExtXProgramDateTime { impl ExtXProgramDateTime {
pub(crate) const PREFIX: &'static str = "#EXT-X-PROGRAM-DATE-TIME:"; pub(crate) const PREFIX: &'static str = "#EXT-X-PROGRAM-DATE-TIME:";
/// Makes a new `ExtXProgramDateTime` tag. /// Makes a new `ExtXProgramDateTime` tag.
pub fn new(date_time: DateTime<FixedOffset>) -> Self { pub fn new(date_time: SingleLineString) -> Self {
ExtXProgramDateTime { date_time } ExtXProgramDateTime { date_time }
} }
/// Returns the `DateTime` of the first sample of the associated media segment. /// Returns the date-time of the first sample of the associated media segment.
pub fn date_time(&self) -> DateTime<FixedOffset> { pub fn date_time(&self) -> &SingleLineString {
self.date_time &self.date_time
} }
/// Returns the protocol compatibility version that this tag requires. /// Returns the protocol compatibility version that this tag requires.
@ -322,7 +321,7 @@ impl ExtXProgramDateTime {
} }
impl fmt::Display for ExtXProgramDateTime { impl fmt::Display for ExtXProgramDateTime {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}{}", Self::PREFIX, self.date_time.to_rfc3339()) write!(f, "{}{}", Self::PREFIX, self.date_time)
} }
} }
impl FromStr for ExtXProgramDateTime { impl FromStr for ExtXProgramDateTime {
@ -331,7 +330,7 @@ impl FromStr for ExtXProgramDateTime {
track_assert!(s.starts_with(Self::PREFIX), ErrorKind::InvalidInput); track_assert!(s.starts_with(Self::PREFIX), ErrorKind::InvalidInput);
let suffix = s.split_at(Self::PREFIX.len()).1; let suffix = s.split_at(Self::PREFIX.len()).1;
Ok(ExtXProgramDateTime { Ok(ExtXProgramDateTime {
date_time: track!(suffix.parse().map_err(|e| ErrorKind::InvalidInput.cause(e)))?, date_time: track!(SingleLineString::new(suffix))?,
}) })
} }
} }
@ -346,8 +345,8 @@ impl FromStr for ExtXProgramDateTime {
pub struct ExtXDateRange { pub struct ExtXDateRange {
pub id: QuotedString, pub id: QuotedString,
pub class: Option<QuotedString>, pub class: Option<QuotedString>,
pub start_date: NaiveDate, pub start_date: QuotedString,
pub end_date: Option<NaiveDate>, pub end_date: Option<QuotedString>,
pub duration: Option<Duration>, pub duration: Option<Duration>,
pub planned_duration: Option<Duration>, pub planned_duration: Option<Duration>,
pub scte35_cmd: Option<QuotedString>, pub scte35_cmd: Option<QuotedString>,
@ -371,13 +370,9 @@ impl fmt::Display for ExtXDateRange {
if let Some(ref x) = self.class { if let Some(ref x) = self.class {
write!(f, ",CLASS={}", x)?; write!(f, ",CLASS={}", x)?;
} }
write!( write!(f, ",START-DATE={}", self.start_date)?;
f,
",START-DATE={:?}",
self.start_date.format("%Y-%m-%d").to_string()
)?;
if let Some(ref x) = self.end_date { if let Some(ref x) = self.end_date {
write!(f, ",END-DATE={:?}", x.format("%Y-%m-%d").to_string())?; write!(f, ",END-DATE={}", x)?;
} }
if let Some(x) = self.duration { if let Some(x) = self.duration {
write!(f, ",DURATION={}", DecimalFloatingPoint::from_duration(x))?; write!(f, ",DURATION={}", DecimalFloatingPoint::from_duration(x))?;
@ -429,20 +424,8 @@ impl FromStr for ExtXDateRange {
match key { match key {
"ID" => id = Some(track!(value.parse())?), "ID" => id = Some(track!(value.parse())?),
"CLASS" => class = Some(track!(value.parse())?), "CLASS" => class = Some(track!(value.parse())?),
"START-DATE" => { "START-DATE" => start_date = Some(track!(value.parse())?),
let s: QuotedString = track!(value.parse())?; "END-DATE" => end_date = Some(track!(value.parse())?),
start_date = Some(track!(
NaiveDate::parse_from_str(&s, "%Y-%m-%d")
.map_err(|e| ErrorKind::InvalidInput.cause(e))
)?);
}
"END-DATE" => {
let s: QuotedString = track!(value.parse())?;
end_date = Some(track!(
NaiveDate::parse_from_str(&s, "%Y-%m-%d")
.map_err(|e| ErrorKind::InvalidInput.cause(e))
)?);
}
"DURATION" => { "DURATION" => {
let seconds: DecimalFloatingPoint = track!(value.parse())?; let seconds: DecimalFloatingPoint = track!(value.parse())?;
duration = Some(seconds.to_duration()); duration = Some(seconds.to_duration());