Skip to content

Include AM/PM Selector in Rolldate #56

@AsiaCobra

Description

@AsiaCobra

Hi,

I would like to request an enhancement to the Rolldate library to include an AM/PM selector for time selection. This feature would be very useful for users who prefer the 12-hour clock format.

Proposed Changes:

Add an AM/PM selector to the UI.
Update the date confirmation logic to handle AM/PM values.

Example:

// Add AM/PM selector to the UI
ul += `<div id="${domId.AP}"><ul class="wheel-scroll">`;
ul += `<li class="wheel-item ${date.getHours() < 12 ? 'active' : ''}" data-index="0">AM</li>`;
ul += `<li class="wheel-item ${date.getHours() >= 12 ? 'active' : ''}" data-index="1">PM</li>`;
ul += '</ul></div>';

// Handle AM/PM value in the confirm method
if (_this.getSelected(_this.scroll['AP']) === 'PM' && hours < 12) {
  hours += 12;
} else if (_this.getSelected(_this.scroll['AP']) === 'AM' && hours === 12) {
  hours = 0;
}
newDate.setHours(hours);

Thank you for considering this enhancement. It would greatly improve the usability of the Rolldate library for many users.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions