Skip to content

Commit e4c5b85

Browse files
restored methods for weekdays
1 parent f9a5887 commit e4c5b85

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/components/Calendar/Week.tsx

Lines changed: 8 additions & 4 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 } from "../../helpers";
6+
import { loadLanguageModule, shortString, ucFirst } from "../../helpers";
77

88
dayjs.extend(weekday);
99

@@ -43,9 +43,13 @@ 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-
{dayjs(`2022-11-${6 + (item + startDateModifier)}`)
47-
.locale(i18n)
48-
.format("ddd")}
46+
{ucFirst(
47+
shortString(
48+
dayjs(`2022-11-${6 + (item + startDateModifier)}`)
49+
.locale(i18n)
50+
.format("ddd")
51+
)
52+
)}
4953
</div>
5054
))}
5155
</div>

src/helpers/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ 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+
6068
export function formatDate(date: dayjs.Dayjs, format = "YYYY-MM-DD") {
6169
return date.format(format);
6270
}

0 commit comments

Comments
 (0)