Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

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

Thomas Kaulb4e60e796d41
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9a4a6de61e..a46f60b574 100644
--- a/CHANGELOG.md
+++ b/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 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
diff --git a/apps/api/src/app/portfolio/current-rate.service.ts b/apps/api/src/app/portfolio/current-rate.service.ts
index 5a3daddb57..151b0b14ab 100644
--- a/apps/api/src/app/portfolio/current-rate.service.ts
+++ b/apps/api/src/app/portfolio/current-rate.service.ts
@@ -12,9 +12,10 @@ import {
ResponseError
} from '@ghostfolio/common/interfaces';
+import { utc } from '@date-fns/utc';
import { Injectable } from '@nestjs/common';
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 { GetValueObject } from './interfaces/get-value-object.interface';
@@ -38,14 +39,14 @@ export class CurrentRateService {
subscriptionType
}: GetValuesParams): Promise<GetValuesObject> {
const dataProviderInfos: DataProviderInfo[] = [];
+ const today = resetHours(new Date());
const includesToday =
(!dateQuery.lt || isBefore(new Date(), dateQuery.lt)) &&
(!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 today = resetHours(new Date());
const values: GetValueObject[] = [];
if (includesToday) {
@@ -128,7 +129,7 @@ export class CurrentRateService {
return (
currentValue.dataSource === dataSource &&
currentValue.symbol === symbol &&
- isToday(currentValue.date)
+ isSameDay(currentValue.date, today, { in: utc })
);
});
@@ -190,12 +191,15 @@ export class CurrentRateService {
return response;
}
- private containsToday(dates: Date[]): boolean {
- for (const date of dates) {
- if (isToday(date)) {
- return true;
- }
- }
- return false;
+ private containsToday({
+ dates,
+ today
+ }: {
+ dates: Date[];
+ today: Date;
+ }): boolean {
+ return dates.some((date) => {
+ return isSameDay(date, today, { in: utc });
+ });
}
}