Calendar updates. Responsive CSS updates.

This commit is contained in:
Mike Cao 2020-09-13 11:33:57 -07:00
parent a0cb278463
commit f59594e4cd
18 changed files with 127 additions and 42 deletions

View file

@ -88,14 +88,16 @@ export function getDateRange(value) {
}
export function getDateRangeValues(startDate, endDate) {
if (differenceInHours(endDate, startDate) <= 48) {
return { startDate: startOfHour(startDate), endDate: endOfHour(endDate), unit: 'hour' };
let unit = 'year';
if (differenceInHours(endDate, startDate) <= 72) {
unit = 'hour';
} else if (differenceInCalendarDays(endDate, startDate) <= 90) {
return { startDate: startOfDay(startDate), endDate: endOfDay(endDate), unit: 'day' };
unit = 'day';
} else if (differenceInCalendarMonths(endDate, startDate) <= 24) {
return { startDate: startOfMonth(startDate), endDate: endOfMonth(endDate), unit: 'month' };
unit = 'month';
}
return { startDate: startOfYear(startDate), endDate: endOfYear(endDate), unit: 'year' };
return { startDate: startOfDay(startDate), endDate: endOfDay(endDate), unit };
}
const dateFuncs = {
@ -112,11 +114,12 @@ export function getDateArray(data, startDate, endDate, unit) {
function findData(t) {
const x = data.find(e => {
if (unit === 'day') {
const [year, month, day] = e.t.split('-');
return normalize(new Date(year, month - 1, day)).getTime() === t.getTime();
if (unit === 'hour') {
return normalize(new Date(e.t)).getTime() === t.getTime();
}
return normalize(new Date(e.t)).getTime() === t.getTime();
const [year, month, day] = e.t.split('-');
return normalize(new Date(year, month - 1, day)).getTime() === t.getTime();
});
return x?.y || 0;

View file

@ -37,9 +37,9 @@ export const menuOptions = [
{ label: 'Nederlands (Dutch)', value: 'nl-NL', display: 'NL' },
{ label: 'Deutsch (German)', value: 'de-DE', display: 'DE' },
{ label: '日本語 (Japanese)', value: 'ja-JP', display: '日本語' },
{ label: 'Español (Mexicano)', value: 'es-MX', display: 'ES' },
{ label: 'Русский (Russian)', value: 'ru-RU', display: 'РУ' },
{ label: 'Turkish', value: 'tr-TR', display: 'TR' },
{ label: 'Español (Mexicano)', value: 'es-MX', display: 'ES' },
];
export function dateFormat(date, str, locale) {