From a457f50c951c90cf66637a53ef3d1b2c321aee3b Mon Sep 17 00:00:00 2001 From: Igor Kamyshev Date: Sun, 3 Mar 2019 19:47:39 +0200 Subject: [PATCH] fix(converter): fix normalize date --- back/src/money/application/CurrencyConverter.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/back/src/money/application/CurrencyConverter.ts b/back/src/money/application/CurrencyConverter.ts index 66932456..90f51c5f 100644 --- a/back/src/money/application/CurrencyConverter.ts +++ b/back/src/money/application/CurrencyConverter.ts @@ -1,5 +1,5 @@ import { Injectable } from '@nestjs/common' -import { differenceInDays, startOfHour } from 'date-fns' +import { differenceInDays, startOfHour, startOfDay } from 'date-fns' import { EntitySaver } from '@back/db/EntitySaver' import { Currency } from '@shared/enum/Currency' @@ -28,8 +28,8 @@ export class CurrencyConverter { return amount } - const normalizedDate = startOfHour(when) - const normalizedNowDate = startOfHour(new Date()) + const normalizedDate = startOfDay(when) + const normalizedNowDate = startOfDay(new Date()) const rate = await this.getExistRate(from, to, normalizedDate) .catch(() => this.getActualRate(from, to, normalizedDate))