Skip to content

Commit

Permalink
refactor(datepicker): only show 12h not 24h and add a AM/PM as suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
hudy9x committed Mar 14, 2024
1 parent 301d34c commit 049f1ac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/shared-ui/src/components/DatePicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export default function DatePicker({
const showTimer = () => {
if (!enableTimer) return null
const { hour, min } = extractHourNMin(time)
const suffix = +hour > 12 ? 'PM' : 'AM'
const suffix = +hour >= 12 ? 'PM' : 'AM'
return (
<span className="pl-1">
at {+hour > 12 ? +hour - 12 : hour}:{min} {suffix}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export default function CalMonthTaskList({ day }: { day: Date }) {

const h = dueDate.getHours()
const m = dueDate.getMinutes()
const time = `${h > 9 ? h : '0' + h}:${m > 9 ? m : '0' + m}`
const time = `${h > 9 ? (h > 12 ? h - 12 : h) : '0' + h}:${
m > 9 ? m : '0' + m
} ${h >= 12 ? 'PM' : 'AM'}`

return (
<CalMonthTask
Expand Down

0 comments on commit 049f1ac

Please sign in to comment.