mirror of
https://github.com/cjfranko/NTP-Timeturner.git
synced 2025-11-08 18:32:02 +00:00
feat: Set system time to 10am when setting date
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
parent
65dd107514
commit
c9c6320abb
1 changed files with 4 additions and 3 deletions
|
|
@ -157,19 +157,20 @@ pub fn nudge_clock(microseconds: i64) -> Result<(), ()> {
|
||||||
pub fn set_date(date: &str) -> Result<(), ()> {
|
pub fn set_date(date: &str) -> Result<(), ()> {
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
{
|
{
|
||||||
|
let datetime_str = format!("{} 10:00:00", date);
|
||||||
let success = Command::new("sudo")
|
let success = Command::new("sudo")
|
||||||
.arg("date")
|
.arg("date")
|
||||||
.arg("--set")
|
.arg("--set")
|
||||||
.arg(date)
|
.arg(&datetime_str)
|
||||||
.status()
|
.status()
|
||||||
.map(|s| s.success())
|
.map(|s| s.success())
|
||||||
.unwrap_or(false);
|
.unwrap_or(false);
|
||||||
|
|
||||||
if success {
|
if success {
|
||||||
log::info!("Set system date to {}", date);
|
log::info!("Set system date and time to {}", datetime_str);
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
log::error!("Failed to set system date");
|
log::error!("Failed to set system date and time");
|
||||||
Err(())
|
Err(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue