ui: fix custom comparison period generation

This commit is contained in:
nick-delirium 2025-02-12 15:53:21 +01:00
parent d70ecab1d9
commit 57041140cb
No known key found for this signature in database
GPG key ID: 93ABD695DF5FDBA0
3 changed files with 6 additions and 10 deletions

View file

@ -53,12 +53,8 @@ function WidgetDateRange({
onChangeComparison(newPeriod);
}, 1)
} else {
const day = 86400000;
const originalPeriodLength = Math.ceil(
(period.end - period.start) / day
);
const start = presetComparison[0];
const end = presetComparison[1] + originalPeriodLength * day;
const start = parseInt(presetComparison[0], 10);
const end = parseInt(presetComparison[1], 10);
// @ts-ignore
const compRange = new Period({
@ -102,7 +98,7 @@ function WidgetDateRange({
compPeriod={compPeriod}
onChange={onChangePeriod}
onChangeComparison={onChangeComparison}
right={true}
right={false}
isAnt={true}
useButtonStyle={true}
comparison={true}

View file

@ -290,7 +290,7 @@ function AndDateRange({
}}
>
<div
className={cn('absolute top-0 mt-10 z-40', { 'right-0': right })}
className={cn('absolute top-0 mt-10 z-40', right ? 'right-0' : 'left-0')}
style={{
width: isUSLocale ? '542px' : '500px',
fontSize: '14px',

View file

@ -90,9 +90,9 @@ export default Record(
if (!period.rangeName || period.rangeName === CUSTOM_RANGE) {
const isLuxon = DateTime.isDateTime(period.start);
let start = isLuxon
? period.start : DateTime.fromMillis(period.start || 0, { zone: Settings.defaultZone });
? period.start : DateTime.fromMillis(parseInt(period.start || 0, 10), { zone: Settings.defaultZone });
let end = isLuxon
? period.end : DateTime.fromMillis(period.end || 0, { zone: Settings.defaultZone });
? period.end : DateTime.fromMillis(parseInt(period.end || 0, 10), { zone: Settings.defaultZone });
if (period.substract) {
const delta = substractValues[period.substract]
start = start.minus(delta);