MCPcopy Create free account
hub / github.com/apache/datafusion / format_time

Method format_time

datafusion/spark/src/function/string/format_string.rs:2227–2253  ·  view source on GitHub ↗
(
        &self,
        writer: &mut String,
        timestamp_nanos: i64,
        timezone: &Option<Arc<str>>,
    )

Source from the content-addressed store, hash-verified

2225 }
2226
2227 fn format_time(
2228 &self,
2229 writer: &mut String,
2230 timestamp_nanos: i64,
2231 timezone: &Option<Arc<str>>,
2232 ) -> Result<()> {
2233 let upper = self.conversion_type.is_upper();
2234 match &self.conversion_type {
2235 ConversionType::TimeLower(time_format)
2236 | ConversionType::TimeUpper(time_format) => {
2237 let formatted =
2238 self.format_time_component(timestamp_nanos, *time_format, timezone)?;
2239 let result = if upper {
2240 formatted.to_uppercase()
2241 } else {
2242 formatted
2243 };
2244 write!(writer, "{result}")
2245 .map_err(|e| exec_datafusion_err!("Write error: {}", e))?;
2246 Ok(())
2247 }
2248 _ => exec_err!(
2249 "Invalid conversion type for time: {:?}",
2250 self.conversion_type
2251 ),
2252 }
2253 }
2254
2255 fn format_date(&self, writer: &mut String, date_days: i64) -> Result<()> {
2256 // Convert days since epoch to timestamp in nanoseconds

Callers 2

formatMethod · 0.80
format_dateMethod · 0.80

Calls 2

is_upperMethod · 0.80
format_time_componentMethod · 0.80

Tested by

no test coverage detected