Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 2 additions & 28 deletions shai-core/src/runners/coder/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,35 +91,9 @@ pub fn get_os_version() -> String {

/// Get today's date in YYYY-MM-DD format
pub fn get_today() -> String {
use std::time::{SystemTime, UNIX_EPOCH};
use chrono::Local;

let now = SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs();

// Simple date calculation (days since Unix epoch)
let days = now / 86400;
let (year, month, day) = days_to_ymd(days as i32);

format!("{:04}-{:02}-{:02}", year, month, day)
}

// Helper function to convert days since Unix epoch to year/month/day
fn days_to_ymd(days: i32) -> (i32, i32, i32) {
let days = days + 719163; // Adjust for Unix epoch (1970-01-01)

let era = days / 146097;
let doe = days % 146097;
let yoe = (doe - doe/1460 + doe/36524 - doe/146096) / 365;
let year = yoe + era * 400;
let doy = doe - (365*yoe + yoe/4 - yoe/100);
let mp = (5*doy + 2) / 153;
let day = doy - (153*mp + 2) / 5 + 1;
let month = mp + if mp < 10 { 3 } else { -9 };
let year = year + if month <= 2 { 1 } else { 0 };

(year, month, day)
Local::now().date_naive().format("%Y-%m-%d").to_string()
}

/// Get the current git branch
Expand Down