Skip to content

Commit

Permalink
Change: Drop parsing of $Date (#1552)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjnicola authored Jan 25, 2024
1 parent b12152b commit 476cc3f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions rust/storage/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ impl AsUnixTimeStamp for String {
impl AsUnixTimeStamp for &str {
fn as_timestamp(&self) -> Option<i64> {
let to_parse = {
// transforms `$Date: wanted (....) $` to wanted
self.splitn(2, "$Date: ")
.filter_map(|x| x.split(" $").next())
.filter_map(|x| x.split(" (").next())
// transforms `wanted (....)` to wanted
self.splitn(2, " (")
.find(|x| !x.is_empty())
.unwrap_or_default()
};
Expand All @@ -60,7 +58,7 @@ mod tests {

#[test]
fn date_string() {
let example = "$Date: 2018-09-07 11:08:31 +0200 (Fri, 07 Sep 2018) $";
let example = "2018-09-07 11:08:31 +0200 (Fri, 07 Sep 2018)";
assert_eq!(example.as_timestamp(), Some(1536311311));
}

Expand Down

0 comments on commit 476cc3f

Please sign in to comment.