vtcode_core/prompts/
temporal.rs1use chrono::{DateTime, Local, Utc};
2
3pub fn generate_temporal_date_context(use_utc: bool) -> String {
20 if use_utc {
21 let now: DateTime<Utc> = Utc::now();
22 format!("\n\nCurrent date (UTC): {}", now.format("%A, %B %d, %Y"))
23 } else {
24 let now: DateTime<Local> = Local::now();
25 format!("\n\nCurrent date: {}", now.format("%A, %B %d, %Y %Z"))
26 }
27}
28
29#[cfg(test)]
30mod tests {
31 use super::*;
32
33 #[test]
34 fn test_temporal_date_context_is_cache_friendly() {
35 let utc = generate_temporal_date_context(true);
36 assert!(utc.contains("Current date (UTC):"), "Should include UTC date label");
37 assert!(!utc.contains(" at "), "Date-only context must not carry clock time");
38 assert_eq!(utc.matches(':').count(), 1, "Date-only context must not carry clock time");
40 let local = generate_temporal_date_context(false);
41 assert!(local.contains("Current date:"), "Should include date label");
42 assert!(!local.contains(" at "), "Date-only context must not carry clock time");
43 assert!(!local.contains("Current date and time"), "Must not use the per-second label");
44 }
45}