Skip to main content

format_time

Function format_time 

Source
pub fn format_time(
    format_str: &str,
    source: TimeFormatStyle,
    target: TimeFormatStyle,
) -> String
Expand description

Convert a time format string from one dialect style to another.

§Arguments

  • format_str - The format string to convert
  • source - The source format style
  • target - The target format style

§Returns

The converted format string with specifiers replaced according to the target style. Literal text (not matching any known specifier) is preserved as-is.

§Example

use sqlglot_rust::dialects::time::{format_time, TimeFormatStyle};

let result = format_time("%Y-%m-%d", TimeFormatStyle::Strftime, TimeFormatStyle::Postgres);
assert_eq!(result, "YYYY-MM-DD");