use chrono::{DateTime, Local, Utc};
pub fn generate_temporal_date_context(use_utc: bool) -> String {
if use_utc {
let now: DateTime<Utc> = Utc::now();
format!("\n\nCurrent date (UTC): {}", now.format("%A, %B %d, %Y"))
} else {
let now: DateTime<Local> = Local::now();
format!("\n\nCurrent date: {}", now.format("%A, %B %d, %Y %Z"))
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_temporal_date_context_is_cache_friendly() {
let utc = generate_temporal_date_context(true);
assert!(utc.contains("Current date (UTC):"), "Should include UTC date label");
assert!(!utc.contains(" at "), "Date-only context must not carry clock time");
assert_eq!(utc.matches(':').count(), 1, "Date-only context must not carry clock time");
let local = generate_temporal_date_context(false);
assert!(local.contains("Current date:"), "Should include date label");
assert!(!local.contains(" at "), "Date-only context must not carry clock time");
assert!(!local.contains("Current date and time"), "Must not use the per-second label");
}
}