Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: readable timestamp string #31

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

fiag
Copy link

@fiag fiag commented Aug 23, 2021

convert the Unix timestamp to a readable date time string.

@fiag fiag changed the title Add feature for readable timestamp string feat: readable timestamp string Aug 23, 2021
}
#[cfg(readable_timestamp)]
{
let time = Local::now().format("%Y-%m-%d %H:%M:%S%.f%z");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be Local::now().to_rfc3339() or Local::now().to_rfc3339_opts(SecondsFormat::Millis, true). iso 8601+3339 is widely used in json logs. See https://docs.rs/chrono/latest/chrono/struct.DateTime.html?search=#method.to_rfc3339_opts

Personally, I'd prefer this to be in UTC anyway because I don't like to depend on a server's timezone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants