Feature/reduce bundle size (#234) (#36)

Co-authored-by: Juan Camilo González <j.gonzalezj@uniandes.edu.co>
Co-authored-by: msramalho <19508417+msramalho@users.noreply.github.com>
This commit is contained in:
Lachlan Kermode
2022-04-08 05:20:16 -04:00
committed by GitHub
parent 250c43a301
commit 1c08ed9378
7 changed files with 583 additions and 423 deletions

View File

@@ -1,8 +1,12 @@
import moment from "moment";
import customParseFormat from "dayjs/plugin/customParseFormat";
import dayjs from "dayjs";
import hash from "object-hash";
import { timeFormatDefaultLocale } from "d3";
import { ASSOCIATION_MODES, POLYGON_CLIP_PATH } from "./constants";
dayjs.extend(customParseFormat);
let { DATE_FMT, TIME_FMT } = process.env;
if (!DATE_FMT) DATE_FMT = "MM/DD/YYYY";
if (!TIME_FMT) TIME_FMT = "HH:mm";
@@ -16,7 +20,7 @@ export function getPathLeaf(path) {
export function calcDatetime(date, time) {
if (!time) time = "00:00";
const dt = moment(`${date} ${time}`, `${DATE_FMT} ${TIME_FMT}`);
const dt = dayjs(`${date} ${time}`, `${DATE_FMT} ${TIME_FMT}`);
return dt.toDate();
}
@@ -499,15 +503,14 @@ export function makeNiceDate(datetime) {
/**
* Sets the default locale for d3 to format dates in each available language.
* @param {Object} d3 - An instance of D3
*/
export function setD3Locale(d3) {
export function setD3Locale() {
const languages = {
"es-MX": require("./data/es-MX.json"),
};
if (language !== "es-US" && languages[language]) {
d3.timeFormatDefaultLocale(languages[language]);
timeFormatDefaultLocale(languages[language]);
}
}