Skip to content

Commit

Permalink
fix time format
Browse files Browse the repository at this point in the history
  • Loading branch information
meteorgan committed Jan 3, 2025
1 parent 6d659c8 commit ad7eac7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions core/src/raw/chrono_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use chrono::Utc;

use crate::*;

/// Parse dateimt from rfc2822.
/// Parse datetime from rfc2822.
///
/// For example: `Fri, 28 Nov 2014 21:00:09 +0900`
pub fn parse_datetime_from_rfc2822(s: &str) -> Result<DateTime<Utc>> {
Expand All @@ -34,7 +34,7 @@ pub fn parse_datetime_from_rfc2822(s: &str) -> Result<DateTime<Utc>> {
})
}

/// Parse dateimt from rfc3339.
/// Parse datetime from rfc3339.
///
/// For example: `2014-11-28T21:00:09+09:00`
pub fn parse_datetime_from_rfc3339(s: &str) -> Result<DateTime<Utc>> {
Expand Down Expand Up @@ -62,3 +62,10 @@ pub fn parse_datetime_from_from_timestamp(s: i64) -> Result<DateTime<Utc>> {

Ok(st.into())
}

/// format datetime to rfc1123
///
/// for example: `Sun, 06 Nov 1994 08:49:37 GMT`
pub fn to_rfc_1123(s: DateTime<Utc>) -> String {
s.format("%a, %d %b %Y %H:%M:%S GMT").to_string()
}
4 changes: 2 additions & 2 deletions core/src/services/s3/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,11 +408,11 @@ impl S3Core {
}

if let Some(if_modified_since) = args.if_modified_since() {
req = req.header(IF_MODIFIED_SINCE, if_modified_since.to_rfc2822());
req = req.header(IF_MODIFIED_SINCE, to_rfc_1123(if_modified_since));
}

if let Some(if_unmodified_since) = args.if_unmodified_since() {
req = req.header(IF_UNMODIFIED_SINCE, if_unmodified_since.to_rfc2822());
req = req.header(IF_UNMODIFIED_SINCE, to_rfc_1123(if_unmodified_since));
}

// Set SSE headers.
Expand Down

0 comments on commit ad7eac7

Please sign in to comment.