Skip to content

Commit

Permalink
fix #105
Browse files Browse the repository at this point in the history
  • Loading branch information
baoyachi committed Jul 19, 2022
1 parent 8552641 commit 143fcac
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "shadow-rs"
version = "0.14.1"
version = "0.15.0"
authors = ["baoyachi <[email protected]>"]
edition = "2021"
description = "A build-time information stored in your rust project"
Expand Down
2 changes: 1 addition & 1 deletion example_shadow/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use shadow_rs::{shadow, Format};
shadow!(build);

fn main() {
let local_time = shadow_rs::DateTime::new().human_format();
let local_time = shadow_rs::DateTime::now().human_format();
println!("{}", local_time);

Command::new("example_shadow")
Expand Down
8 changes: 4 additions & 4 deletions src/data_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub fn now_data_time() -> DateTime {
// https://reproducible-builds.org/docs/source-date-epoch/
println!("cargo:rerun-if-env-changed=SOURCE_DATE_EPOCH");
match std::env::var_os("SOURCE_DATE_EPOCH") {
None => DateTime::new(),
None => DateTime::now(),
Some(timestamp) => {
let epoch = timestamp
.into_string()
Expand All @@ -33,17 +33,17 @@ pub fn now_data_time() -> DateTime {

impl Default for DateTime {
fn default() -> Self {
Self::new()
Self::now()
}
}

impl DateTime {
pub fn new() -> Self {
pub fn now() -> Self {
Self::local_now().unwrap_or_else(|_| DateTime::Utc(OffsetDateTime::now_utc()))
}

pub fn offset_datetime() -> OffsetDateTime {
let date_time = Self::new();
let date_time = Self::now();
match date_time {
DateTime::Local(time) | DateTime::Utc(time) => time,
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ impl Shadow {
// Author by:https://www.github.com/baoyachi
// The build script repository:https://github.com/baoyachi/shadow-rs
// Create time by:{}"#,
DateTime::new().human_format()
DateTime::now().human_format()
);
writeln!(&self.f, "{}\n\n", desc)?;
Ok(())
Expand Down

0 comments on commit 143fcac

Please sign in to comment.