chart formatting + version increasing

This commit is contained in:
MaTeMaTuK 2021-08-15 15:07:23 +03:00
parent fd5f4ed65e
commit be51811818
3 changed files with 18 additions and 13 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "gantt-task-react", "name": "gantt-task-react",
"version": "0.3.5", "version": "0.3.6",
"description": "Interactive Gantt Chart for React with TypeScript.", "description": "Interactive Gantt Chart for React with TypeScript.",
"author": "MaTeMaTuK <maksym.vikarii@gmail.com>", "author": "MaTeMaTuK <maksym.vikarii@gmail.com>",
"homepage": "https://github.com/MaTeMaTuK/gantt-task-react", "homepage": "https://github.com/MaTeMaTuK/gantt-task-react",

View File

@ -3,7 +3,10 @@ import styles from "./task-list-table.module.css";
import { Task } from "../../types/public-types"; import { Task } from "../../types/public-types";
const localeDateStringCache = {}; const localeDateStringCache = {};
const toLocaleDateStringFactory = (locale: string) => (date: Date, dateTimeOptions: Intl.DateTimeFormatOptions) => { const toLocaleDateStringFactory = (locale: string) => (
date: Date,
dateTimeOptions: Intl.DateTimeFormatOptions
) => {
const key = date.toString(); const key = date.toString();
let lds = localeDateStringCache[key]; let lds = localeDateStringCache[key];
if (!lds) { if (!lds) {
@ -12,6 +15,12 @@ const toLocaleDateStringFactory = (locale: string) => (date: Date, dateTimeOptio
} }
return lds; return lds;
}; };
const dateTimeOptions: Intl.DateTimeFormatOptions = {
weekday: "short",
year: "numeric",
month: "long",
day: "numeric",
};
export const TaskListTableDefault: React.FC<{ export const TaskListTableDefault: React.FC<{
rowHeight: number; rowHeight: number;
@ -32,13 +41,9 @@ export const TaskListTableDefault: React.FC<{
locale, locale,
onExpanderClick, onExpanderClick,
}) => { }) => {
const dateTimeOptions: Intl.DateTimeFormatOptions = { const toLocaleDateString = useMemo(() => toLocaleDateStringFactory(locale), [
weekday: "short", locale,
year: "numeric", ]);
month: "long",
day: "numeric",
};
const toLocaleDateString = useMemo(() => toLocaleDateStringFactory(locale), [locale]);
return ( return (
<div <div
@ -108,4 +113,3 @@ export const TaskListTableDefault: React.FC<{
</div> </div>
); );
}; };

View File

@ -12,7 +12,10 @@ type DateHelperScales =
| "millisecond"; | "millisecond";
const intlDTCache = {}; const intlDTCache = {};
const getCachedDateTimeFormat = (locString: string | string[], opts: DateTimeFormatOptions = {}): DateTimeFormat => { const getCachedDateTimeFormat = (
locString: string | string[],
opts: DateTimeFormatOptions = {}
): DateTimeFormat => {
const key = JSON.stringify([locString, opts]); const key = JSON.stringify([locString, opts]);
let dtf = intlDTCache[key]; let dtf = intlDTCache[key];
if (!dtf) { if (!dtf) {
@ -22,7 +25,6 @@ const getCachedDateTimeFormat = (locString: string | string[], opts: DateTimeFor
return dtf; return dtf;
}; };
export const addToDate = ( export const addToDate = (
date: Date, date: Date,
quantity: number, quantity: number,
@ -187,4 +189,3 @@ export const getWeekNumberISO8601 = (date: Date) => {
export const getDaysInMonth = (month: number, year: number) => { export const getDaysInMonth = (month: number, year: number) => {
return new Date(year, month + 1, 0).getDate(); return new Date(year, month + 1, 0).getDate();
}; };