Skip to content

Commit

Permalink
Kate / OPT-347 / Opening the Duration Tab for the first time will sho…
Browse files Browse the repository at this point in the history
…w incorrect expiry time (deriv-com#9732)

* chore: draft

* feat: expant function and hardcoded date

* refactor: add usage moment library

* chore: remove extra space
  • Loading branch information
kate-deriv authored and Mahdiyeh Amirkhani committed Aug 30, 2023
1 parent 00734b3 commit 927a098
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React from 'react';
import { Tabs, TickPicker, Numpad, RelativeDatepicker, Text } from '@deriv/components';
import { isEmptyObject, addComma, getDurationMinMaxValues } from '@deriv/shared';
import { Localize, localize } from '@deriv/translations';

import { observer, useStore } from '@deriv/stores';
import { useTraderStore } from 'Stores/useTraderStores';
import moment from 'moment';

const submit_label = localize('OK');

Expand Down Expand Up @@ -167,8 +167,10 @@ const Numbers = observer(
};

const setExpiryDate = (epoch, duration) => {
if (trade_duration_unit !== 'd') {
return moment.utc().add(Number(duration), 'days').format('D MMM YYYY, [23]:[59]:[59] [GMT +0]');
}
let expiry_date = new Date((epoch - trade_duration * 24 * 60 * 60) * 1000);

if (duration) {
expiry_date = new Date(expiry_date.getTime() + duration * 24 * 60 * 60 * 1000);
}
Expand Down

0 comments on commit 927a098

Please sign in to comment.