Skip to content

Commit

Permalink
Update time requirement from 0.1 to 0.2 (#541)
Browse files Browse the repository at this point in the history
Updates the requirements on [time](https://github.com/time-rs/time) to permit the latest version.
- [Release notes](https://github.com/time-rs/time/releases)
- [Changelog](https://github.com/time-rs/time/blob/v0.2.26/CHANGELOG.md)
- [Commits](time-rs/time@0.1.35...v0.2.26)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dominic <git@msrd0.de>
  • Loading branch information
dependabot[bot] and msrd0 committed Apr 29, 2021
1 parent 97d1ba3 commit fe7d15b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/sessions/custom_data_type/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ gotham_derive = { path = "../../../gotham_derive" }
mime = "0.3"
serde = "1"
serde_derive = "1"
time = "0.1"
time = "0.2"
cookie = "0.15"
6 changes: 5 additions & 1 deletion examples/sessions/custom_data_type/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use gotham::pipeline::single::single_pipeline;
use gotham::router::builder::*;
use gotham::router::Router;
use gotham::state::{FromState, State};
use time::{Format, OffsetDateTime};

// A custom type for storing data associated with the user's session.
#[derive(Clone, Deserialize, Serialize, StateData)]
Expand Down Expand Up @@ -40,9 +41,12 @@ fn get_handler(mut state: State) -> (State, String) {
let visit_data: &mut Option<VisitData> =
SessionData::<Option<VisitData>>::borrow_mut_from(&mut state);
let old_count = maybe_visit_data.map(|v| v.count).unwrap_or(0);
let last_visit = OffsetDateTime::try_now_local()
.unwrap_or_else(|_| OffsetDateTime::now_utc())
.format(Format::Rfc3339);
*visit_data = Some(VisitData {
count: old_count + 1,
last_visit: format!("{}", time::now().rfc3339()),
last_visit,
});
}

Expand Down

0 comments on commit fe7d15b

Please sign in to comment.