Bugfix/change date creation from string using parse iso (#2236)
* Change date creation using parseISO parseISO provides consistent date parsing across different time zones * Update changelog
This commit is contained in:
parent
3e98f097ef
commit
6c9779fb0d
@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
- Added the data export feature to the user account page
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed an issue with the date parsing in the historical market data editor of the admin control panel
|
||||
|
||||
## 1.300.0 - 2023-08-11
|
||||
|
||||
### Added
|
||||
|
@ -38,7 +38,7 @@ import {
|
||||
import { REQUEST } from '@nestjs/core';
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
import { DataSource, MarketData, Prisma, SymbolProfile } from '@prisma/client';
|
||||
import { isDate } from 'date-fns';
|
||||
import { isDate, parseISO } from 'date-fns';
|
||||
import { StatusCodes, getReasonPhrase } from 'http-status-codes';
|
||||
|
||||
import { AdminService } from './admin.service';
|
||||
@ -233,7 +233,7 @@ export class AdminController {
|
||||
);
|
||||
}
|
||||
|
||||
const date = new Date(dateString);
|
||||
const date = parseISO(dateString);
|
||||
|
||||
if (!isDate(date)) {
|
||||
throw new HttpException(
|
||||
@ -333,7 +333,7 @@ export class AdminController {
|
||||
);
|
||||
}
|
||||
|
||||
const date = new Date(dateString);
|
||||
const date = parseISO(dateString);
|
||||
|
||||
return this.marketDataService.updateMarketData({
|
||||
data: { marketPrice: data.marketPrice, state: 'CLOSE' },
|
||||
|
@ -10,6 +10,7 @@ import { AuthGuard } from '@nestjs/passport';
|
||||
import { StatusCodes, getReasonPhrase } from 'http-status-codes';
|
||||
|
||||
import { ExchangeRateService } from './exchange-rate.service';
|
||||
import { parseISO } from 'date-fns';
|
||||
|
||||
@Controller('exchange-rate')
|
||||
export class ExchangeRateController {
|
||||
@ -23,7 +24,7 @@ export class ExchangeRateController {
|
||||
@Param('dateString') dateString: string,
|
||||
@Param('symbol') symbol: string
|
||||
): Promise<IDataProviderHistoricalResponse> {
|
||||
const date = new Date(dateString);
|
||||
const date = parseISO(dateString);
|
||||
|
||||
const exchangeRate = await this.exchangeRateService.getExchangeRate({
|
||||
date,
|
||||
|
@ -21,6 +21,7 @@ import { isDate, isEmpty } from 'lodash';
|
||||
import { LookupItem } from './interfaces/lookup-item.interface';
|
||||
import { SymbolItem } from './interfaces/symbol-item.interface';
|
||||
import { SymbolService } from './symbol.service';
|
||||
import { parseISO } from 'date-fns';
|
||||
|
||||
@Controller('symbol')
|
||||
export class SymbolController {
|
||||
@ -93,7 +94,7 @@ export class SymbolController {
|
||||
@Param('dateString') dateString: string,
|
||||
@Param('symbol') symbol: string
|
||||
): Promise<IDataProviderHistoricalResponse> {
|
||||
const date = new Date(dateString);
|
||||
const date = parseISO(dateString);
|
||||
|
||||
if (!isDate(date)) {
|
||||
throw new HttpException(
|
||||
|
@ -154,7 +154,7 @@ export class AdminMarketDataDetailComponent implements OnChanges, OnInit {
|
||||
day: string;
|
||||
yearMonth: string;
|
||||
}) {
|
||||
const date = new Date(`${yearMonth}-${day}`);
|
||||
const date = parseISO(`${yearMonth}-${day}`);
|
||||
const marketPrice = this.marketDataByMonth[yearMonth]?.[day]?.marketPrice;
|
||||
|
||||
if (isSameDay(date, new Date())) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user