@@ -1490,8 +1490,6 @@ def format_day_time_interval_for_display(
14901490 elif isinstance (cell , str ):
14911491 # Raw string that needs to be formatted (e.g., "1 01:01:01.7878")
14921492 interval_str = cell
1493- else :
1494- return str (cell ).replace ("\n " , "\\ n" )
14951493
14961494 field_names = {
14971495 DayTimeIntervalType .DAY : "DAY" ,
@@ -1557,48 +1555,26 @@ def format_seconds_with_precision(
15571555 seconds_value : Union [float , decimal .Decimal ]
15581556 ) -> str :
15591557 """Format seconds with full precision, preserving trailing zeros for proper padding"""
1560- if isinstance (seconds_value , decimal .Decimal ):
1561- # Use Decimal precision formatting
1562- if seconds_value == int (seconds_value ):
1563- return f"{ int (seconds_value ):02d} "
1564- else :
1565- # For fractional seconds, ensure proper leading zero padding
1566- integer_part = int (seconds_value )
1567- if integer_part < 10 :
1568- # Format with leading zero for the integer part
1569- formatted = f"{ seconds_value :.6f} " .rstrip ("0" )
1570- if formatted .endswith ("." ):
1571- return f"{ integer_part :02d} "
1572- # Replace the integer part with zero-padded version
1573- decimal_part = formatted .split ("." , 1 )[1 ]
1574- return f"{ integer_part :02d} .{ decimal_part } "
1575- else :
1576- # For >= 10, use normal formatting
1577- formatted = f"{ seconds_value :.6f} " .rstrip ("0" )
1578- if formatted .endswith ("." ):
1579- return f"{ integer_part } "
1580- return formatted
1558+ # Unified formatting logic for both Decimal and float types
1559+ if seconds_value == int (seconds_value ):
1560+ return f"{ int (seconds_value ):02d} "
15811561 else :
1582- # Float precision formatting (original logic)
1583- if seconds_value == int (seconds_value ):
1584- return f"{ int (seconds_value ):02d} "
1562+ # For fractional seconds, ensure proper leading zero padding
1563+ integer_part = int (seconds_value )
1564+ if integer_part < 10 :
1565+ # Format with leading zero for the integer part
1566+ formatted = f"{ seconds_value :.6f} " .rstrip ("0" )
1567+ if formatted .endswith ("." ):
1568+ return f"{ integer_part :02d} "
1569+ # Replace the integer part with zero-padded version
1570+ decimal_part = formatted .split ("." , 1 )[1 ]
1571+ return f"{ integer_part :02d} .{ decimal_part } "
15851572 else :
1586- # For fractional seconds, ensure proper leading zero padding
1587- integer_part = int (seconds_value )
1588- if integer_part < 10 :
1589- # Format with leading zero for the integer part
1590- formatted = f"{ seconds_value :.6f} " .rstrip ("0" )
1591- if formatted .endswith ("." ):
1592- return f"{ integer_part :02d} "
1593- # Replace the integer part with zero-padded version
1594- decimal_part = formatted .split ("." , 1 )[1 ]
1595- return f"{ integer_part :02d} .{ decimal_part } "
1596- else :
1597- # For >= 10, use normal formatting
1598- formatted = f"{ seconds_value :.6f} " .rstrip ("0" )
1599- if formatted .endswith ("." ):
1600- return f"{ integer_part } "
1601- return formatted
1573+ # For >= 10, use normal formatting
1574+ formatted = f"{ seconds_value :.6f} " .rstrip ("0" )
1575+ if formatted .endswith ("." ):
1576+ return f"{ integer_part } "
1577+ return formatted
16021578
16031579 # For single field intervals, extract just that component
16041580 if start_field == end_field :
0 commit comments