Skip to content

Commit

Permalink
fix default 12 hour display
Browse files Browse the repository at this point in the history
  • Loading branch information
dorkyboi committed Feb 3, 2023
1 parent 5de7e07 commit 94b19f9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "react-native-calendar-timetable",
"description": "Timetable (schedule) component for React Native applications",
"version": "1.0.3",
"version": "1.0.4",
"private": false,
"main": "./lib/Timetable.js",
"types": "./lib/Timetable.d.ts",
Expand Down
14 changes: 11 additions & 3 deletions src/components/Hours.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,17 @@ function Hours({
}: HoursProps) {
const timeFontSize = timeStyle?.fontSize || 14;

const renderTime = (hour: number) => is12Hour
? (hour > 12 ? (hour - 12 + ' pm') : hour + ' am')
: (hour > 9 ? '' : '0') + (hour === 24 ? '00' : hour) + ':00';
const renderTime = (hour: number) => {
if (is12Hour) {
switch (hour) {
case 0: case 24: return '12 am';
case 12: return '12 pm';
default:
return (hour > 12 ? (hour - 12 + ' pm') : hour + ' am');
}
}
return (hour > 9 ? '' : '0') + (hour === 24 ? '00' : hour) + ':00';
};

return (
<View>
Expand Down

0 comments on commit 94b19f9

Please sign in to comment.