diff options
author | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2017-08-18 17:47:37 +0200 |
---|---|---|
committer | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2017-08-25 11:05:36 +0200 |
commit | f6276b3b6fecce2b160ed8bdc62a3e87439249e4 (patch) | |
tree | d1c69e7f786b8693fb13dd816624794eb6b07ae7 /server/sonar-web/src/main/js/apps/quality-profiles/utils.ts | |
parent | 1ddf3ee7dbf26116afb767003a8a0698965c4f70 (diff) | |
download | sonarqube-f6276b3b6fecce2b160ed8bdc62a3e87439249e4.tar.gz sonarqube-f6276b3b6fecce2b160ed8bdc62a3e87439249e4.zip |
SONAR-9385 SONAR-9436 Replace moment with react-intl
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.ts | 12 |
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) => |