Skip to content

Cookies with chrono DateTime #634

Answered by jbr
DreamTexX asked this question in Q&A
Apr 15, 2024 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

Hi, thanks for using trillium!

It's been a bit since I've used the chrono crate but looking at the docs suggests you should be able to convert between them by way of a unix timestamp:

let offset_datetime = time::OffsetDateTime::from_unix_timestamp(chrono_datetime.timestamp()).unwrap();

For other use cases you might want to use sub second precision, but there really isn't any reason to be that precise for cookie expiry. We also don't need to retain the timezone offset because expiry doesn't happen in any particular timezone.

Trillium currently exposes types from the cookie crate, so their choice of time library is also exposed.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@DreamTexX
Comment options

@jbr
Comment options

jbr Apr 15, 2024
Maintainer

Answer selected by DreamTexX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants