Skip to content

Commit

Permalink
Fix #5719: Calendar paste 12:01 AM
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Jan 10, 2024
1 parent cd6537c commit 96ed4de
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 54 deletions.
8 changes: 4 additions & 4 deletions components/doc/button/linkdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function LinkDoc(props) {
const code = {
basic: `
<Button label="Link" link />
<a href="https://react.dev" target="_blank" rel="noopener noreferrer" class="p-button font-bold">
<a href="https://react.dev" target="_blank" rel="noopener noreferrer" className="p-button font-bold">
Navigate
</a>
`,
Expand All @@ -18,7 +18,7 @@ export default function LinkDemo() {
return (
<div className="card flex justify-content-center">
<Button label="Link" link />
<a href="https://react.dev" target="_blank" rel="noopener noreferrer" class="p-button font-bold">
<a href="https://react.dev" target="_blank" rel="noopener noreferrer" className="p-button font-bold">
Navigate
</a>
Expand All @@ -34,7 +34,7 @@ export default function LinkDemo() {
return (
<div className="card flex justify-content-center">
<Button label="Link" link />
<a href="https://react.dev" target="_blank" rel="noopener noreferrer" class="p-button font-bold">
<a href="https://react.dev" target="_blank" rel="noopener noreferrer" className="p-button font-bold">
Navigate
</a>
</div>
Expand All @@ -52,7 +52,7 @@ export default function LinkDemo() {
</DocSectionText>
<div className="card flex justify-content-center">
<Button label="Link" link />
<a href="https://react.dev" target="_blank" rel="noopener noreferrer" class="p-button font-bold">
<a href="https://react.dev" target="_blank" rel="noopener noreferrer" className="p-button font-bold">
Navigate
</a>
</div>
Expand Down
48 changes: 24 additions & 24 deletions components/doc/calendar/icondoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@ export default function IconDemo() {
return (
<div className="card flex flex-wrap gap-3 p-fluid">
<div class="flex-auto">
<label labelFor="buttondisplay" class="font-bold block mb-2">
<div className="flex-auto">
<label htmlFor="buttondisplay" className="font-bold block mb-2">
Button Display
</label>
<Calendar id="buttondisplay" value={date} onChange={(e) => setDate(e.value)} showIcon />
</div>
<div class="flex-auto">
<label labelFor="buttondisplay" class="font-bold block mb-2">
<div className="flex-auto">
<label htmlFor="buttondisplay" className="font-bold block mb-2">
Icon Display
</label>
<Calendar value={date} onChange={(e) => setDate(e.value)} showIcon iconDisplay="input" />
<Calendar value={date} onChange={(e) => setDate(e.value)} showIcon />
</div>
<div class="flex-auto">
<label labelFor="buttondisplay" class="font-bold block mb-2">
<div className="flex-auto">
<label htmlFor="buttondisplay" className="font-bold block mb-2">
Icon Template
</label>
<Calendar value={date} onChange={(e) => setDate(e.value)} showIcon timeOnly iconDisplay="input" icon={() => <i className="pi pi-clock" />} />
<Calendar value={date} onChange={(e) => setDate(e.value)} showIcon timeOnly icon={() => <i className="pi pi-clock" />} />
</div>
</div>
)
Expand All @@ -53,25 +53,25 @@ export default function IconDemo() {
return (
<div className="card flex flex-wrap gap-3 p-fluid">
<div class="flex-auto">
<label labelFor="buttondisplay" class="font-bold block mb-2">
<div className="flex-auto">
<label htmlFor="buttondisplay" className="font-bold block mb-2">
Button Display
</label>
<Calendar id="buttondisplay" value={date} onChange={(e) => setDate(e.value)} showIcon />
</div>
<div class="flex-auto">
<label labelFor="buttondisplay" class="font-bold block mb-2">
<div className="flex-auto">
<label htmlFor="buttondisplay" className="font-bold block mb-2">
Icon Display
</label>
<Calendar value={date} onChange={(e) => setDate(e.value)} showIcon iconDisplay="input" />
<Calendar value={date} onChange={(e) => setDate(e.value)} showIcon />
</div>
<div class="flex-auto">
<label labelFor="buttondisplay" class="font-bold block mb-2">
<div className="flex-auto">
<label htmlFor="buttondisplay" className="font-bold block mb-2">
Icon Template
</label>
<Calendar value={date} onChange={(e) => setDate(e.value)} showIcon timeOnly iconDisplay="input" icon={() => <i className="pi pi-clock" />} />
<Calendar value={date} onChange={(e) => setDate(e.value)} showIcon timeOnly icon={() => <i className="pi pi-clock" />} />
</div>
</div>
)
Expand All @@ -87,25 +87,25 @@ export default function IconDemo() {
</p>
</DocSectionText>
<div className="card flex flex-wrap gap-3 p-fluid">
<div class="flex-auto">
<label labelFor="buttondisplay" class="font-bold block mb-2">
<div className="flex-auto">
<label htmlFor="buttondisplay" className="font-bold block mb-2">
Button Display
</label>
<Calendar id="buttondisplay" value={date} onChange={(e) => setDate(e.value)} showIcon />
</div>
<div class="flex-auto">
<label labelFor="buttondisplay" class="font-bold block mb-2">
<div className="flex-auto">
<label htmlFor="buttondisplay" className="font-bold block mb-2">
Icon Display
</label>

<Calendar value={date} onChange={(e) => setDate(e.value)} showIcon iconDisplay="input" />
<Calendar value={date} onChange={(e) => setDate(e.value)} showIcon />
</div>
<div class="flex-auto">
<label labelFor="buttondisplay" class="font-bold block mb-2">
<div className="flex-auto">
<label htmlFor="buttondisplay" className="font-bold block mb-2">
Icon Template
</label>

<Calendar value={date} onChange={(e) => setDate(e.value)} showIcon timeOnly iconDisplay="input" icon={() => <i className="pi pi-clock" />} />
<Calendar value={date} onChange={(e) => setDate(e.value)} showIcon timeOnly icon={() => <i className="pi pi-clock" />} />
</div>
</div>
<DocSectionCode code={code} />
Expand Down
12 changes: 6 additions & 6 deletions components/doc/panel/templatedoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export function TemplateDoc(props) {
</div>
<div>
<Menu model={items} popup ref={configMenu} id="config_menu" />
<button class="p-panel-header-icon p-link mr-2" onClick={(e) => configMenu?.current?.toggle(e)}>
<span class="pi pi-cog"></span>
<button className="p-panel-header-icon p-link mr-2" onClick={(e) => configMenu?.current?.toggle(e)}>
<span className="pi pi-cog"></span>
</button>
{options.togglerElement}
</div>
Expand Down Expand Up @@ -107,8 +107,8 @@ export default function TemplateDemo() {
</div>
<div>
<Menu model={items} popup ref={configMenu} id="config_menu" />
<button class="p-panel-header-icon p-link mr-2" onClick={(e) => configMenu?.current?.toggle(e)}>
<span class="pi pi-cog"></span>
<button className="p-panel-header-icon p-link mr-2" onClick={(e) => configMenu?.current?.toggle(e)}>
<span className="pi pi-cog"></span>
</button>
{options.togglerElement}
</div>
Expand Down Expand Up @@ -178,8 +178,8 @@ export default function TemplateDemo() {
</div>
<div>
<Menu model={items} popup ref={configMenu} id="config_menu" />
<button class="p-panel-header-icon p-link mr-2" onClick={(e) => configMenu?.current?.toggle(e)}>
<span class="pi pi-cog"></span>
<button className="p-panel-header-icon p-link mr-2" onClick={(e) => configMenu?.current?.toggle(e)}>
<span className="pi pi-cog"></span>
</button>
{options.togglerElement}
</div>
Expand Down
24 changes: 12 additions & 12 deletions components/doc/ripple/customdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ import { Ripple } from '@/components/lib/ripple/Ripple';
export function CustomDoc(props) {
const code = {
basic: `
<div class="p-ripple p-5 border-round border-radius-10 shadow-2">
<div className="p-ripple p-5 border-round border-radius-10 shadow-2">
Green
<Ripple
pt={{
root: { style: { background: 'rgba(75, 175, 80, 0.3)' } }
}}
/>
</div>
<div class="p-ripple p-5 border-round border-radius-10 shadow-2">
<div className="p-ripple p-5 border-round border-radius-10 shadow-2">
Orange
<Ripple
pt={{
root: { style: { background: 'rgba(255, 193, 6, 0.3)' } }
}}
/>
</div>
<div class="p-ripple p-5 border-round border-radius-10 shadow-2">
<div className="p-ripple p-5 border-round border-radius-10 shadow-2">
Purple
<Ripple
pt={{
Expand All @@ -37,23 +37,23 @@ import { Ripple } from 'primereact/ripple';
export default function CustomDemo() {
return (
<div className="card flex justify-content-center align-items-center gap-2">
<div class="p-ripple p-5 border-round border-radius-10 shadow-2">
<div className="p-ripple p-5 border-round border-radius-10 shadow-2">
Green
<Ripple
pt={{
root: { style: { background: 'rgba(75, 175, 80, 0.3)' } }
}}
/>
</div>
<div class="p-ripple p-5 border-round border-radius-10 shadow-2">
<div className="p-ripple p-5 border-round border-radius-10 shadow-2">
Orange
<Ripple
pt={{
root: { style: { background: 'rgba(255, 193, 6, 0.3)' } }
}}
/>
</div>
<div class="p-ripple p-5 border-round border-radius-10 shadow-2">
<div className="p-ripple p-5 border-round border-radius-10 shadow-2">
Purple
<Ripple
pt={{
Expand All @@ -72,23 +72,23 @@ import { Ripple } from 'primereact/ripple';
export default function CustomDemo() {
return (
<div className="card flex justify-content-center align-items-center gap-2">
<div class="p-ripple p-5 border-round border-radius-10 shadow-2">
<div className="p-ripple p-5 border-round border-radius-10 shadow-2">
Green
<Ripple
pt={{
root: { style: { background: 'rgba(75, 175, 80, 0.3)' } }
}}
/>
</div>
<div class="p-ripple p-5 border-round border-radius-10 shadow-2">
<div className="p-ripple p-5 border-round border-radius-10 shadow-2">
Orange
<Ripple
pt={{
root: { style: { background: 'rgba(255, 193, 6, 0.3)' } }
}}
/>
</div>
<div class="p-ripple p-5 border-round border-radius-10 shadow-2">
<div className="p-ripple p-5 border-round border-radius-10 shadow-2">
Purple
<Ripple
pt={{
Expand All @@ -110,23 +110,23 @@ export default function CustomDemo() {
</p>
</DocSectionText>
<div className="card flex justify-content-center align-items-center gap-2">
<div class="p-ripple p-5 border-round border-radius-10 shadow-2">
<div className="p-ripple p-5 border-round border-radius-10 shadow-2">
Green
<Ripple
pt={{
root: { style: { background: 'rgba(75, 175, 80, 0.3)' } }
}}
/>
</div>
<div class="p-ripple p-5 border-round border-radius-10 shadow-2">
<div className="p-ripple p-5 border-round border-radius-10 shadow-2">
Orange
<Ripple
pt={{
root: { style: { background: 'rgba(255, 193, 6, 0.3)' } }
}}
/>
</div>
<div class="p-ripple p-5 border-round border-radius-10 shadow-2">
<div className="p-ripple p-5 border-round border-radius-10 shadow-2">
Purple
<Ripple
pt={{
Expand Down
12 changes: 6 additions & 6 deletions components/doc/toolbar/customdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ export function CustomDoc(props) {

const endContent = (
<React.Fragment>
<div class="flex align-items-center gap-2">
<div className="flex align-items-center gap-2">
<Avatar image="https://primefaces.org/cdn/primevue/images/avatar/amyelsner.png" shape="circle" />
<span class="font-bold text-bluegray-50">Amy Elsner</span>
<span className="font-bold text-bluegray-50">Amy Elsner</span>
</div>
</React.Fragment>
);
Expand Down Expand Up @@ -104,9 +104,9 @@ export default function CustomDemo() {
const endContent = (
<React.Fragment>
<div class="flex align-items-center gap-2">
<div className="flex align-items-center gap-2">
<Avatar image="https://primefaces.org/cdn/primevue/images/avatar/amyelsner.png" shape="circle" />
<span class="font-bold text-bluegray-50">Amy Elsner</span>
<span className="font-bold text-bluegray-50">Amy Elsner</span>
</div>
</React.Fragment>
);
Expand Down Expand Up @@ -165,9 +165,9 @@ export default function CustomDemo() {
const endContent = (
<React.Fragment>
<div class="flex align-items-center gap-2">
<div className="flex align-items-center gap-2">
<Avatar image="https://primefaces.org/cdn/primevue/images/avatar/amyelsner.png" shape="circle" />
<span class="font-bold text-bluegray-50">Amy Elsner</span>
<span className="font-bold text-bluegray-50">Amy Elsner</span>
</div>
</React.Fragment>
);
Expand Down
10 changes: 8 additions & 2 deletions components/lib/calendar/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2310,8 +2310,14 @@ export const Calendar = React.memo(
if (isNaN(h) || isNaN(m) || h > 23 || m > 59 || (props.hourFormat === '12' && h > 12) || (props.showSeconds && (isNaN(s) || s > 59)) || (props.showMillisec && (isNaN(s) || s > 1000))) {
throw new Error('Invalid time');
} else {
if (props.hourFormat === '12' && h !== 12 && ampm === 'PM') {
h += 12;
if (props.hourFormat === '12') {
if (h !== 12 && ampm === 'PM') {
h += 12;
}

if (h === 12 && ampm === 'AM') {
h -= 12;
}
}

return { hour: h, minute: m, second: s, millisecond: ms };
Expand Down

0 comments on commit 96ed4de

Please sign in to comment.