Skip to content

Commit

Permalink
If expiry date shows up as a string, convert it to a number before se…
Browse files Browse the repository at this point in the history
…nding to Composer
  • Loading branch information
rhystmills committed Jan 9, 2025
1 parent 271e9d7 commit cb122c4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions public/video-ui/src/util/getComposerData.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@ import { getStore } from './storeAccessor';
import { impossiblyDistantDate } from '../constants/dates';
import VideoUtils from './video';

export const getDateAsNumber = (date) => {
if (typeof date === "string"){
return moment(date).valueOf();
}
else return date;
};

export function getComposerData(video) {

const isTrainingMode = getStore().getState().config.isTrainingMode;

const expiryDate = video.contentChangeDetails && video.contentChangeDetails.expiry && video.contentChangeDetails.expiry.date
const cleanedExpiryDate = getDateAsNumber(expiryDate);
const scheduledLaunch = VideoUtils.getScheduledLaunch(video);
const embargo = VideoUtils.getEmbargo(video);
const isEmbargoedIndefinitely = isTrainingMode || (embargo && embargo >= impossiblyDistantDate);
Expand All @@ -30,7 +37,7 @@ export function getComposerData(video) {
thumbnail: video.trailImage && video.trailImage.assets.length > 0
? parseComposerDataFromImage(video.trailImage, video.trailText)
: null,
expiryDate: expiryDate,
expiryDate: cleanedExpiryDate,
scheduledLaunch: scheduledLaunch,
requestedScheduledLaunch: scheduledLaunch,
embargoedUntil: embargoedUntil,
Expand Down

0 comments on commit cb122c4

Please sign in to comment.