Skip to main content

yyyymmdd

Function yyyymmdd 

Source
pub fn yyyymmdd(
    timestamp: i64,
    separator: Option<&str>,
) -> Result<String, Error>
Expand description

Formats a timestamp as “yyyy-MM-dd”

This function now includes validation using TimestampUtils::validate_timestamp().

§Arguments

  • timestamp - Timestamp in milliseconds since Unix epoch
  • separator - Optional separator between year, month, day (defaults to “-”)

§Example

use ccxt_core::time::yyyymmdd;

let ts = 1704110400000;
let formatted = yyyymmdd(ts, None).unwrap();
assert_eq!(formatted, "2024-01-01");

let formatted_slash = yyyymmdd(ts, Some("/")).unwrap();
assert_eq!(formatted_slash, "2024/01/01");