Browse Source

Bugfix/check for today in time zones behind UTC (#8056)

* Fix check for today in time zones behind UTC

* Update changelog
pull/8059/head
Thomas Kaul 5 days ago
committed by GitHub
parent
commit
b4e60e796d
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 26
      apps/api/src/app/portfolio/current-rate.service.ts

1
CHANGELOG.md

@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed the missing thousands separator of 4-digit numbers in certain locales - Fixed the missing thousands separator of 4-digit numbers in certain locales
- Fixed an issue where holdings without a market price have been valued at the unit price of a dividend, a fee, an interest or a liability - Fixed an issue where holdings without a market price have been valued at the unit price of a dividend, a fee, an interest or a liability
- Fixed the check for today in the current rate service for instances running in a time zone behind UTC
## 3.79.0 - 2026-10-04 ## 3.79.0 - 2026-10-04

26
apps/api/src/app/portfolio/current-rate.service.ts

@ -12,9 +12,10 @@ import {
ResponseError ResponseError
} from '@ghostfolio/common/interfaces'; } from '@ghostfolio/common/interfaces';
import { utc } from '@date-fns/utc';
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { Type as ActivityType } from '@prisma/client'; import { Type as ActivityType } from '@prisma/client';
import { isBefore, isToday } from 'date-fns'; import { isBefore, isSameDay } from 'date-fns';
import { isEmpty, uniqBy } from 'lodash-es'; import { isEmpty, uniqBy } from 'lodash-es';
import { GetValueObject } from './interfaces/get-value-object.interface'; import { GetValueObject } from './interfaces/get-value-object.interface';
@ -38,14 +39,14 @@ export class CurrentRateService {
subscriptionType subscriptionType
}: GetValuesParams): Promise<GetValuesObject> { }: GetValuesParams): Promise<GetValuesObject> {
const dataProviderInfos: DataProviderInfo[] = []; const dataProviderInfos: DataProviderInfo[] = [];
const today = resetHours(new Date());
const includesToday = const includesToday =
(!dateQuery.lt || isBefore(new Date(), dateQuery.lt)) && (!dateQuery.lt || isBefore(new Date(), dateQuery.lt)) &&
(!dateQuery.gte || isBefore(dateQuery.gte, new Date())) && (!dateQuery.gte || isBefore(dateQuery.gte, new Date())) &&
(!dateQuery.in || this.containsToday(dateQuery.in)); (!dateQuery.in || this.containsToday({ today, dates: dateQuery.in }));
const quoteErrors: ResponseError['errors'] = []; const quoteErrors: ResponseError['errors'] = [];
const today = resetHours(new Date());
const values: GetValueObject[] = []; const values: GetValueObject[] = [];
if (includesToday) { if (includesToday) {
@ -128,7 +129,7 @@ export class CurrentRateService {
return ( return (
currentValue.dataSource === dataSource && currentValue.dataSource === dataSource &&
currentValue.symbol === symbol && currentValue.symbol === symbol &&
isToday(currentValue.date) isSameDay(currentValue.date, today, { in: utc })
); );
}); });
@ -190,12 +191,15 @@ export class CurrentRateService {
return response; return response;
} }
private containsToday(dates: Date[]): boolean { private containsToday({
for (const date of dates) { dates,
if (isToday(date)) { today
return true; }: {
} dates: Date[];
} today: Date;
return false; }): boolean {
return dates.some((date) => {
return isSameDay(date, today, { in: utc });
});
} }
} }

Loading…
Cancel
Save