mirror of
https://github.com/zyllian/webdog.git
synced 2025-05-10 02:26:42 -07:00
add utility for getting a current timestamp
This commit is contained in:
parent
f3a9662ca9
commit
5e9a23d789
1 changed files with 14 additions and 0 deletions
14
src/main.rs
14
src/main.rs
|
@ -7,11 +7,14 @@ use zyl_site::Site;
|
||||||
enum Mode {
|
enum Mode {
|
||||||
Build,
|
Build,
|
||||||
Serve,
|
Serve,
|
||||||
|
Now,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "serve")]
|
#[cfg(feature = "serve")]
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> eyre::Result<()> {
|
async fn main() -> eyre::Result<()> {
|
||||||
|
use time::{format_description::well_known::Rfc3339, OffsetDateTime};
|
||||||
|
|
||||||
#[cfg(feature = "color-eyre")]
|
#[cfg(feature = "color-eyre")]
|
||||||
color_eyre::install()?;
|
color_eyre::install()?;
|
||||||
|
|
||||||
|
@ -22,6 +25,9 @@ async fn main() -> eyre::Result<()> {
|
||||||
if arg == "serve" {
|
if arg == "serve" {
|
||||||
mode = Mode::Serve;
|
mode = Mode::Serve;
|
||||||
break;
|
break;
|
||||||
|
} else if arg == "now" {
|
||||||
|
mode = Mode::Now;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +37,14 @@ async fn main() -> eyre::Result<()> {
|
||||||
site.build_once()?
|
site.build_once()?
|
||||||
}
|
}
|
||||||
Mode::Serve => site.serve().await?,
|
Mode::Serve => site.serve().await?,
|
||||||
|
Mode::Now => {
|
||||||
|
let time = OffsetDateTime::now_utc();
|
||||||
|
println!(
|
||||||
|
"{}",
|
||||||
|
time.format(&Rfc3339)
|
||||||
|
.expect("failed to format the current time")
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Build complete!");
|
println!("Build complete!");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue