Skip to content

Commit

Permalink
Change date format in build-info ordering and use SVG instead of PNG
Browse files Browse the repository at this point in the history
The NaiveDate type doesn't include any time or timezone information, so
I'm explicitly formatting as year-month-day ("%Y-%m-%d").
  • Loading branch information
jtgeibel committed Mar 1, 2018
1 parent 6cdb0e7 commit 881ff2c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/templates/crate/build-info.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div id='crates-heading'>
<div class="wide">
<div class='info'>
<img class='logo crate' src="/assets/crate.png"/>
<img class='logo crate' src="/assets/crate.svg"/>
<h1>Build info for {{ name }}</h1>
<h2>{{ version }}</h2>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/tests/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ fn publish_build_info() {

let json = ::json::<R>(&mut response);

let nightly_key_string = String::from("2017-01-25T00:00:00+00:00");
let nightly_key_string = String::from("2017-01-25");
assert_eq!(
json.build_info.ordering.get("nightly"),
Some(&vec![nightly_key_string.clone()])
Expand All @@ -218,7 +218,7 @@ fn publish_build_info() {
vec![nightly_key_string]
);

let beta_key_string = String::from("2017-01-20T00:00:00+00:00");
let beta_key_string = String::from("2017-01-20");
assert_eq!(
json.build_info.ordering.get("beta"),
Some(&vec![beta_key_string.clone()])
Expand Down
18 changes: 9 additions & 9 deletions src/version/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use std::str::FromStr;

use chrono::{DateTime, NaiveDate, Utc};
use chrono::NaiveDate;
use conduit::{Request, Response};
use diesel::prelude::*;

Expand Down Expand Up @@ -81,8 +81,8 @@ pub fn authors(req: &mut Request) -> CargoResult<Response> {
// "build_info": {
// "id": 1,
// "ordering": {
// "nightly": ["2017-07-26T00:00:00Z"],
// "beta": ["2017-07-18T00:00:00Z"],
// "nightly": ["2017-07-26"],
// "beta": ["2017-07-18"],
// "stable": ["1.19.0"]
// },
// "stable": {
Expand All @@ -91,10 +91,10 @@ pub fn authors(req: &mut Request) -> CargoResult<Response> {
// "1.18.0": { "x86_64-pc-windows-gnu": false }
// },
// "beta": {
// "2017-07-18T00:00:00Z": { "x86_64-apple-darwin": false }
// "2017-07-18": { "x86_64-apple-darwin": false }
// },
// "nightly": {
// "2017-07-26T00:00:00Z": { "x86_64-apple-darwin": true }
// "2017-07-26": { "x86_64-apple-darwin": true }
// }
// }
// }
Expand Down Expand Up @@ -159,18 +159,18 @@ pub fn build_info(req: &mut Request) -> CargoResult<Response> {
stables.into_iter().map(|s| s.to_string()).collect(),
);

fn naive_date_to_rfc3339(date: NaiveDate) -> String {
DateTime::<Utc>::from_utc(date.and_hms(0, 0, 0), Utc).to_rfc3339()
fn naive_date_to_string(date: NaiveDate) -> String {
date.format("%Y-%m-%d").to_string()
}

encodable_build_info.ordering.insert(
String::from("beta"),
betas.into_iter().map(naive_date_to_rfc3339).collect(),
betas.into_iter().map(naive_date_to_string).collect(),
);

encodable_build_info.ordering.insert(
String::from("nightly"),
nightlies.into_iter().map(naive_date_to_rfc3339).collect(),
nightlies.into_iter().map(naive_date_to_string).collect(),
);

#[derive(Serialize, Debug)]
Expand Down

0 comments on commit 881ff2c

Please sign in to comment.