From fe540045fcebf7ffeefa2b79d43a194503d38442 Mon Sep 17 00:00:00 2001 From: SergeantPanda Date: Sat, 18 Oct 2025 21:06:27 -0500 Subject: [PATCH] Enhancement: Add a {time} and {time24} output for better output formatting of the time. --- apps/output/views.py | 26 ++++++++++++++++++++++ frontend/src/components/forms/DummyEPG.jsx | 22 +++++++++--------- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/apps/output/views.py b/apps/output/views.py index 34cc4db5..baf603a0 100644 --- a/apps/output/views.py +++ b/apps/output/views.py @@ -494,6 +494,32 @@ def generate_custom_dummy_programs(channel_id, channel_name, now, num_days, cust # Merge title groups, time groups, and date groups for template formatting all_groups = {**groups, **time_groups, **date_groups} + + # Add formatted time strings for better display (handles minutes intelligently) + if time_info: + hour_24 = time_info['hour'] + minute = time_info['minute'] + + # Format 24-hour time string - only include minutes if non-zero + if minute > 0: + all_groups['time24'] = f"{hour_24}:{minute:02d}" + else: + all_groups['time24'] = f"{hour_24:02d}:00" + + # Convert 24-hour to 12-hour format for {time} placeholder + # Note: hour_24 is ALWAYS in 24-hour format at this point (converted earlier if needed) + ampm = 'AM' if hour_24 < 12 else 'PM' + hour_12 = hour_24 + if hour_24 == 0: + hour_12 = 12 + elif hour_24 > 12: + hour_12 = hour_24 - 12 + + # Format 12-hour time string - only include minutes if non-zero + if minute > 0: + all_groups['time'] = f"{hour_12}:{minute:02d} {ampm}" + else: + all_groups['time'] = f"{hour_12} {ampm}" # Generate programs programs = [] diff --git a/frontend/src/components/forms/DummyEPG.jsx b/frontend/src/components/forms/DummyEPG.jsx index 8f273118..e305d0b1 100644 --- a/frontend/src/components/forms/DummyEPG.jsx +++ b/frontend/src/components/forms/DummyEPG.jsx @@ -402,7 +402,7 @@ const DummyEPGForm = ({ epg, isOpen, onClose }) => { id="title_template" name="title_template" label="Title Template" - description="Format the EPG title using extracted groups. Example: {league} - {team1} vs {team2} @ {hour}:{minute}{ampm}" + description="Format the EPG title using extracted groups. Use {time} (12-hour: '10 PM') or {time24} (24-hour: '22:00'). Example: {league} - {team1} vs {team2} @ {time}" placeholder="{league} - {team1} vs {team2}" value={titleTemplate} onChange={(e) => { @@ -416,8 +416,8 @@ const DummyEPGForm = ({ epg, isOpen, onClose }) => { id="description_template" name="description_template" label="Description Template" - description="Format the EPG description using extracted groups. Example: Watch {team1} take on {team2} at {hour}:{minute}{ampm}!" - placeholder="Watch {team1} take on {team2} in this exciting {league} matchup at {hour}:{minute}{ampm}!" + description="Format the EPG description using extracted groups. Use {time} (12-hour) or {time24} (24-hour). Example: Watch {team1} take on {team2} at {time}!" + placeholder="Watch {team1} take on {team2} in this exciting {league} matchup at {time}!" minRows={2} value={descriptionTemplate} onChange={(e) => { @@ -446,8 +446,8 @@ const DummyEPGForm = ({ epg, isOpen, onClose }) => { id="upcoming_title_template" name="upcoming_title_template" label="Upcoming Title Template" - description="Title for programs before the event starts. Example: Coming Up: {team1} vs {team2}" - placeholder="Coming Up: {team1} vs {team2}" + description="Title for programs before the event starts. Use {time} (12-hour) or {time24} (24-hour). Example: {team1} vs {team2} starting at {time}." + placeholder="{team1} vs {team2} starting at {time}." value={upcomingTitleTemplate} onChange={(e) => { const value = e.target.value; @@ -463,8 +463,8 @@ const DummyEPGForm = ({ epg, isOpen, onClose }) => { id="upcoming_description_template" name="upcoming_description_template" label="Upcoming Description Template" - description="Description for programs before the event. Example: {league} game starts soon - {team1} vs {team2}" - placeholder="{league} game starts soon - {team1} vs {team2}" + description="Description for programs before the event. Use {time} (12-hour) or {time24} (24-hour). Example: Upcoming: Watch the {league} match up where the {team1} take on the {team2} at {time}!" + placeholder="Upcoming: Watch the {league} match up where the {team1} take on the {team2} at {time}!" minRows={2} value={upcomingDescriptionTemplate} onChange={(e) => { @@ -481,8 +481,8 @@ const DummyEPGForm = ({ epg, isOpen, onClose }) => { id="ended_title_template" name="ended_title_template" label="Ended Title Template" - description="Title for programs after the event has ended. Example: Game Over: {team1} vs {team2}" - placeholder="Game Over: {team1} vs {team2}" + description="Title for programs after the event has ended. Use {time} (12-hour) or {time24} (24-hour). Example: {team1} vs {team2} started at {time}." + placeholder="{team1} vs {team2} started at {time}." value={endedTitleTemplate} onChange={(e) => { const value = e.target.value; @@ -498,8 +498,8 @@ const DummyEPGForm = ({ epg, isOpen, onClose }) => { id="ended_description_template" name="ended_description_template" label="Ended Description Template" - description="Description for programs after the event. Example: {league} game has ended - {team1} vs {team2}" - placeholder="{league} game has ended - {team1} vs {team2}" + description="Description for programs after the event. Use {time} (12-hour) or {time24} (24-hour). Example: The {league} match between {team1} and {team2} started at {time}." + placeholder="The {league} match between {team1} and {team2} started at {time}." minRows={2} value={endedDescriptionTemplate} onChange={(e) => {