1
0
mirror of https://github.com/dpc/tagwiki synced 2024-06-18 11:09:55 +00:00
tagwiki/src/util.rs
2020-05-15 00:56:07 -07:00

16 lines
409 B
Rust

use rand::distributions::Alphanumeric;
use rand::Rng;
pub fn random_string(len: usize) -> String {
rand::thread_rng()
.sample_iter(&Alphanumeric)
.take(len)
.collect()
}
/// Now with a fixed offset of the current system timezone
pub fn now() -> chrono::DateTime<chrono::offset::FixedOffset> {
let date = chrono::offset::Local::now();
date.with_timezone(&date.offset())
}