@@ -44,7 +44,7 @@ def _create_timezone_filters(tz_name: str) -> dict:
4444
4545 def format_datetime (
4646 value : str | datetime | None ,
47- fmt : str = "%Y-%m-%d %H:%M:%S %Z " ,
47+ fmt : str = "%Y-%m-%d %H:%M:%S" ,
4848 ) -> str :
4949 """Format a UTC datetime string or object to the configured timezone.
5050
@@ -79,7 +79,7 @@ def format_datetime(
7979 # Fallback to original value if parsing fails
8080 return str (value )[:19 ].replace ("T" , " " ) if value else "-"
8181
82- def format_time (value : str | datetime | None , fmt : str = "%H:%M:%S %Z " ) -> str :
82+ def format_time (value : str | datetime | None , fmt : str = "%H:%M:%S" ) -> str :
8383 """Format just the time portion in the configured timezone."""
8484 return format_datetime (value , fmt )
8585
@@ -89,10 +89,10 @@ def format_date(value: str | datetime | None, fmt: str = "%Y-%m-%d") -> str:
8989
9090 return {
9191 "localtime" : format_datetime ,
92- "localtime_short" : lambda v : format_datetime (v , "%Y-%m-%d %H:%M %Z " ),
92+ "localtime_short" : lambda v : format_datetime (v , "%Y-%m-%d %H:%M" ),
9393 "localdate" : format_date ,
9494 "localtimeonly" : format_time ,
95- "localtimeonly_short" : lambda v : format_time (v , "%H:%M %Z " ),
95+ "localtimeonly_short" : lambda v : format_time (v , "%H:%M" ),
9696 }
9797
9898
@@ -215,6 +215,13 @@ def create_app(
215215 for name , func in tz_filters .items ():
216216 templates .env .filters [name ] = func
217217
218+ # Compute timezone abbreviation (e.g., "GMT", "EST", "PST")
219+ try :
220+ tz = ZoneInfo (settings .tz )
221+ app .state .timezone_abbr = datetime .now (tz ).strftime ("%Z" )
222+ except Exception :
223+ app .state .timezone_abbr = "UTC"
224+
218225 app .state .templates = templates
219226
220227 # Initialize page loader for custom markdown pages
@@ -398,5 +405,5 @@ def get_network_context(request: Request) -> dict:
398405 "custom_pages" : custom_pages ,
399406 "logo_url" : request .app .state .logo_url ,
400407 "version" : __version__ ,
401- "timezone" : request .app .state .timezone ,
408+ "timezone" : request .app .state .timezone_abbr ,
402409 }
0 commit comments