MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / format_timestamp

Function format_timestamp

atomic-cli/src/commands/mod.rs:577–580  ·  view source on GitHub ↗

Format a timestamp for display. Converts a UTC timestamp to local time and formats it in a human-readable format. # Arguments `timestamp` - The UTC timestamp to format # Returns A human-readable string representation of the timestamp. # Example ```rust,ignore let ts = Utc::now(); println!("Created: {}", format_timestamp(&ts)); // Output: "Created: 2024-01-15 10:30:45" ```

(timestamp: &DateTime<Utc>)

Source from the content-addressed store, hash-verified

575/// // Output: "Created: 2024-01-15 10:30:45"
576/// ```
577pub fn format_timestamp(timestamp: &DateTime<Utc>) -> String {
578 let local: DateTime<Local> = timestamp.with_timezone(&Local);
579 local.format("%Y-%m-%d %H:%M:%S").to_string()
580}
581
582/// Format a timestamp in a relative format (e.g., "2 hours ago").
583///

Callers 6

test_format_timestampFunction · 0.85
runMethod · 0.85
runMethod · 0.85
runMethod · 0.85
format_defaultMethod · 0.85

Calls 1

formatMethod · 0.45

Tested by 1

test_format_timestampFunction · 0.68