Skip to content

Commit

Permalink
chart formatting + version increasing
Browse files Browse the repository at this point in the history
  • Loading branch information
MaTeMaTuK committed Aug 15, 2021
1 parent fd5f4ed commit be51811
Showing 3 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gantt-task-react",
"version": "0.3.5",
"version": "0.3.6",
"description": "Interactive Gantt Chart for React with TypeScript.",
"author": "MaTeMaTuK <maksym.vikarii@gmail.com>",
"homepage": "https://github.com/MaTeMaTuK/gantt-task-react",
22 changes: 13 additions & 9 deletions src/components/task-list/task-list-table.tsx
Original file line number Diff line number Diff line change
@@ -3,7 +3,10 @@ import styles from "./task-list-table.module.css";
import { Task } from "../../types/public-types";

const localeDateStringCache = {};
const toLocaleDateStringFactory = (locale: string) => (date: Date, dateTimeOptions: Intl.DateTimeFormatOptions) => {
const toLocaleDateStringFactory = (locale: string) => (
date: Date,
dateTimeOptions: Intl.DateTimeFormatOptions
) => {
const key = date.toString();
let lds = localeDateStringCache[key];
if (!lds) {
@@ -12,6 +15,12 @@ const toLocaleDateStringFactory = (locale: string) => (date: Date, dateTimeOptio
}
return lds;
};
const dateTimeOptions: Intl.DateTimeFormatOptions = {
weekday: "short",
year: "numeric",
month: "long",
day: "numeric",
};

export const TaskListTableDefault: React.FC<{
rowHeight: number;
@@ -32,13 +41,9 @@ export const TaskListTableDefault: React.FC<{
locale,
onExpanderClick,
}) => {
const dateTimeOptions: Intl.DateTimeFormatOptions = {
weekday: "short",
year: "numeric",
month: "long",
day: "numeric",
};
const toLocaleDateString = useMemo(() => toLocaleDateStringFactory(locale), [locale]);
const toLocaleDateString = useMemo(() => toLocaleDateStringFactory(locale), [
locale,
]);

return (
<div
@@ -108,4 +113,3 @@ export const TaskListTableDefault: React.FC<{
</div>
);
};

7 changes: 4 additions & 3 deletions src/helpers/date-helper.ts
Original file line number Diff line number Diff line change
@@ -12,7 +12,10 @@ type DateHelperScales =
| "millisecond";

const intlDTCache = {};
const getCachedDateTimeFormat = (locString: string | string[], opts: DateTimeFormatOptions = {}): DateTimeFormat => {
const getCachedDateTimeFormat = (
locString: string | string[],
opts: DateTimeFormatOptions = {}
): DateTimeFormat => {
const key = JSON.stringify([locString, opts]);
let dtf = intlDTCache[key];
if (!dtf) {
@@ -22,7 +25,6 @@ const getCachedDateTimeFormat = (locString: string | string[], opts: DateTimeFor
return dtf;
};


export const addToDate = (
date: Date,
quantity: number,
@@ -187,4 +189,3 @@ export const getWeekNumberISO8601 = (date: Date) => {
export const getDaysInMonth = (month: number, year: number) => {
return new Date(year, month + 1, 0).getDate();
};

0 comments on commit be51811

Please sign in to comment.