aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/quality-profiles/utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/apps/quality-profiles/utils.ts')
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/utils.ts12
1 files changed, 9 insertions, 3 deletions
diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/utils.ts b/server/sonar-web/src/main/js/apps/quality-profiles/utils.ts
index cc7140c0fd4..d058aa01acd 100644
--- a/server/sonar-web/src/main/js/apps/quality-profiles/utils.ts
+++ b/server/sonar-web/src/main/js/apps/quality-profiles/utils.ts
@@ -18,7 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { sortBy } from 'lodash';
-import * as moment from 'moment';
+import { differenceInYears, isValidDate } from '../../helpers/dates';
import { Profile } from './types';
export function sortProfiles(profiles: Profile[]) {
@@ -65,8 +65,14 @@ export function createFakeProfile(overrides?: any) {
};
}
-export function isStagnant(profile: Profile) {
- return moment().diff(moment(profile.userUpdatedAt), 'years') >= 1;
+export function isStagnant(profile: Profile): boolean {
+ if (profile.userUpdatedAt) {
+ const updateDate = new Date(profile.userUpdatedAt);
+ if (isValidDate(updateDate)) {
+ return differenceInYears(new Date(), updateDate) >= 1;
+ }
+ }
+ return false;
}
export const getProfilesPath = (organization: string | null | undefined) =>