Skip to content

Fix day dropdowns in price config to respect selected month - #1168

Merged
gskjold merged 4 commits into
mainfrom
copilot/fix-days-dropdown-issue
Apr 9, 2026
Merged

gskjold merged 4 commits into
mainfrom
copilot/fix-days-dropdown-issue

Conversation

Copilot AI commented Mar 26, 2026 •

Copy link
Copy Markdown
Contributor

The start/end day dropdowns (rsd/red) in price modifier configuration always offered 1–31 regardless of the selected month, allowing nonsensical dates like Feb 31.

Changes

  • daysInMonth(month) — computes correct day count per month; uses 2024 (leap year) as reference so Feb correctly offers up to 29 days. Returns 31 when no month is selected (value 0).
  • clampDay(dateObj, month) — clamps the bound day value to the new month's max on month change, preventing stale out-of-range selections.
  • rsd/red dropdowns — {length: 31} replaced with {length: daysInMonth(c.s.m)} and {length: daysInMonth(c.e.m)} respectively.
  • rsm/rem selects — on:change handlers call clampDay so switching e.g. from March (day 31) to February automatically resets the day to 29.
function daysInMonth(month) {
    if (month === 0) return 31;
    return new Date(2024, month, 0).getDate();
}

function clampDay(dateObj, month) {
    const max = daysInMonth(month);
    if (dateObj.d > max) dateObj.d = max;
}
Original prompt

This section details on the original issue you should resolve

<issue_title>Days in price configuration are not month-dependent</issue_title>
<issue_description>Describe the bug
When choosing time-dependent fees in price configuration, the days dropdown always goes from 1 to 31, independently of the month chosen.

To Reproduce
Steps to reproduce the behavior:

  1. Go to Settings
  2. Click on Configure Price
  3. Scroll down to any modifier
  4. Click on the dropdown for days
  5. The array goes from 1 to 31

Expected behavior
I expect that the available days to choose depends on the month selected. I don't know what would happen if I selected e.g. Feb 31.

Screenshots

Image

Hardware information:

  • Country: Denmark
  • Meter: Kamstrup
  • Encryption enabled [yes/no]
  • AMS reader: Pow-K+
  • M-bus adapter (if applicable):

Relevant firmware information:

  • Version: v2.5.6
  • MQTT: yes
  • MQTT payload type: home-assistant

</issue_description>

<agent_instructions>The file is PriceConfig.svelte. The dropdowns named rsd and red are always showing 31 days, regardless of month. Please suggest solution where the maximum day is limited to the selected month in rsm and rem respectively</agent_instructions>

Comments on the Issue (you are @copilot in this section)


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Copilot AI changed the title [WIP] Fix days dropdown in price configuration to be month-dependent Fix day dropdowns in price config to respect selected month Mar 26, 2026
Copilot AI requested a review from gskjold March 26, 2026 07:01
@gskjold
gskjold marked this pull request as ready for review March 26, 2026 08:51
@gskjold gskjold added this to the v2.5.7 milestone Apr 9, 2026
@github-actions

github-actions Bot commented Apr 9, 2026

Copy link
Copy Markdown

🔧 PR Build Artifacts

Version: b8fb7e1

All environments built successfully. Download the zip files:

Artifacts expire after 7 days. View workflow run

@gskjold
gskjold merged commit 4673fea into main Apr 9, 2026
7 checks passed
@gskjold
gskjold deleted the copilot/fix-days-dropdown-issue branch April 9, 2026 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Days in price configuration are not month-dependent

2 participants