Skip to content

Commit

Permalink
fix: make the lastUpdatedDate consistent on LPR
Browse files Browse the repository at this point in the history
  • Loading branch information
jajjibhai008 committed Jan 17, 2025
1 parent d7e8a8d commit ceb2212
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/components/Admin/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import AdminSearchForm from './AdminSearchForm';
import EnterpriseAppSkeleton from '../EnterpriseApp/EnterpriseAppSkeleton';

import EnterpriseDataApiService from '../../data/services/EnterpriseDataApiService';
import { formatTimestamp } from '../../utils';
import { formattedLastUpdatedDateInUTC } from '../../utils';

import AdminCardsSkeleton from './AdminCardsSkeleton';
import { SubscriptionData } from '../subscriptions';
Expand Down Expand Up @@ -505,7 +505,7 @@ class Admin extends React.Component {
description="Message to show the last updated date of the data on lpr page"
values={{
timestamp: <FormattedDate
value={formatTimestamp({ timestamp: lastUpdatedDate })}
value={formattedLastUpdatedDateInUTC({ timestamp: lastUpdatedDate })}
year="numeric"
month="long"
day="numeric"
Expand Down
12 changes: 11 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import isNumeric from 'validator/lib/isNumeric';
import { logError } from '@edx/frontend-platform/logging';
import { snakeCaseObject } from '@edx/frontend-platform/utils';

import utc from 'dayjs/plugin/utc';
import { features } from './config';

import {
Expand All @@ -27,16 +28,24 @@ import DegreedIcon from './icons/Degreed.png';
import MoodleIcon from './icons/Moodle.png';
import SAPIcon from './icons/SAP.svg';
import { COURSE_RUN_STATUSES } from './components/ContentHighlights/data/constants';

import LmsApiService from './data/services/LmsApiService';

dayjs.extend(utc);

const formatTimestamp = ({ timestamp, format = 'MMMM D, YYYY' }) => {
if (timestamp) {
return dayjs(timestamp).format(format);
}
return null;
};

const formattedLastUpdatedDateInUTC = ({ timestamp, format = 'MMMM D, YYYY' }) => {
if (timestamp) {
return dayjs(timestamp).utc().format(format);
}
return null;
};

const formatPassedTimestamp = (timestamp) => {
if (timestamp) {
return formatTimestamp({ timestamp });
Expand Down Expand Up @@ -704,4 +713,5 @@ export {
isFalsy,
getTimeStampedFilename,
downloadCsv,
formattedLastUpdatedDateInUTC,
};

0 comments on commit ceb2212

Please sign in to comment.