Skip to content

Commit f9a5887

Browse files
resolved the month issue
1 parent f31c484 commit f9a5887

File tree

4 files changed

+10
-27
lines changed

4 files changed

+10
-27
lines changed

src/components/Calendar/Months.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import dayjs from "dayjs";
22
import React, { useContext } from "react";
33

44
import DatepickerContext from "../../contexts/DatepickerContext";
5-
import { loadLanguageModule, shortString, ucFirst } from "../../helpers";
5+
import { loadLanguageModule } from "../../helpers";
66
import { RoundedButton } from "../utils";
77

88
interface Props {
@@ -23,13 +23,9 @@ const Months: React.FC<Props> = ({ clickMonth }) => {
2323
}}
2424
>
2525
<>
26-
{ucFirst(
27-
shortString(
28-
dayjs(`2022-${1 + item}-01`)
29-
.locale(i18n)
30-
.format("MMM")
31-
)
32-
)}
26+
{dayjs(`2022-${1 + item}-01`)
27+
.locale(i18n)
28+
.format("MMM")}
3329
</>
3430
</RoundedButton>
3531
))}

src/components/Calendar/Week.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import weekday from "dayjs/plugin/weekday";
33
import React, { useContext } from "react";
44

55
import DatepickerContext from "../../contexts/DatepickerContext";
6-
import { loadLanguageModule, shortString, ucFirst } from "../../helpers";
6+
import { loadLanguageModule } from "../../helpers";
77

88
dayjs.extend(weekday);
99

@@ -43,13 +43,9 @@ const Week: React.FC = () => {
4343
<div className="grid grid-cols-7 border-b border-gray-300 dark:border-gray-700 py-2">
4444
{[0, 1, 2, 3, 4, 5, 6].map((item, index) => (
4545
<div key={index} className="tracking-wide text-gray-500 text-center">
46-
{ucFirst(
47-
shortString(
48-
dayjs(`2022-11-${6 + (item + startDateModifier)}`)
49-
.locale(i18n)
50-
.format("ddd")
51-
)
52-
)}
46+
{dayjs(`2022-11-${6 + (item + startDateModifier)}`)
47+
.locale(i18n)
48+
.format("ddd")}
5349
</div>
5450
))}
5551
</div>

src/components/Calendar/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ import {
1111
getNumberOfDay,
1212
loadLanguageModule,
1313
nextMonth,
14-
previousMonth,
15-
shortString
14+
previousMonth
1615
} from "../../helpers";
1716
import {
1817
ChevronLeftIcon,
@@ -263,7 +262,7 @@ const Calendar: React.FC<Props> = ({
263262
hideYears();
264263
}}
265264
>
266-
<>{shortString(calendarData.date.locale(i18n).format("MMM"))}</>
265+
<>{calendarData.date.locale(i18n).format("MMM")}</>
267266
</RoundedButton>
268267
</div>
269268

src/helpers/index.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,6 @@ export function generateArrayNumber(start = 0, end = 0) {
5757
return array;
5858
}
5959

60-
export function shortString(value: string, limit = 3) {
61-
return value.slice(0, limit);
62-
}
63-
64-
export function ucFirst(value: string) {
65-
return `${value[0].toUpperCase()}${value.slice(1, value.length)}`;
66-
}
67-
6860
export function formatDate(date: dayjs.Dayjs, format = "YYYY-MM-DD") {
6961
return date.format(format);
7062
}

0 commit comments

Comments
 (0)