Skip to content

Commit 83c063f

Browse files
committed
Bump to time 0.2
1 parent e51c627 commit 83c063f

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ license = "MIT"
1111
[dependencies]
1212
conduit = "0.9.0-alpha.2"
1313
conduit-mime-types = "0.7"
14-
time = "0.1"
14+
time = { version = "0.2", default-features = false, features = ["std"] }
1515
filetime = "0.2"
1616

1717
[dev-dependencies]

src/lib.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use conduit::{box_error, header, Body, Handler, HandlerResult, RequestExt, Respo
1313
use filetime::FileTime;
1414
use std::fs::File;
1515
use std::path::{Path, PathBuf};
16+
use time::OffsetDateTime;
1617

1718
pub struct Static {
1819
path: PathBuf,
@@ -47,18 +48,14 @@ impl Handler for Static {
4748
return Ok(not_found());
4849
}
4950
let mtime = FileTime::from_last_modification_time(&data);
50-
let ts = time::Timespec {
51-
sec: mtime.unix_seconds() as i64,
52-
nsec: mtime.nanoseconds() as i32,
53-
};
54-
let tm = time::at(ts).to_utc();
51+
let mtime = OffsetDateTime::from_unix_timestamp(mtime.unix_seconds() as i64);
5552

5653
Response::builder()
5754
.header(header::CONTENT_TYPE, mime)
5855
.header(header::CONTENT_LENGTH, data.len())
5956
.header(
6057
header::LAST_MODIFIED,
61-
tm.strftime("%a, %d %b %Y %T GMT").unwrap().to_string(),
58+
mtime.format("%a, %d %b %Y %T GMT"),
6259
)
6360
.body(Body::File(file))
6461
.map_err(box_error)

0 commit comments

Comments
 (0)