diff options
author | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2019-07-11 15:15:35 +0200 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2019-07-11 20:21:09 +0200 |
commit | 60226e8e297485bcbe384dc766930da0a5a1c079 (patch) | |
tree | 84140c9f6d8d0828dbe4db676f8a06a5d6b4b077 /server/sonar-web/src/main/js/helpers/dates.ts | |
parent | 7ae6f6f0968febebf763cf073b09cb6dd2b218d7 (diff) | |
download | sonarqube-60226e8e297485bcbe384dc766930da0a5a1c079.tar.gz sonarqube-60226e8e297485bcbe384dc766930da0a5a1c079.zip |
SC-704 Extract components into sonar-ui-common (#1714)
* SC-704 Extract icons components to sonar-ui-common
* Better typings for theme
* Use sonar-ui-common in extensions
* Extract some helpers
* Extract l10n helper to sonar-ui-common
* Extract requests helper to sonar-ui-common
* Extract part of urls helper
* Move buttons, Tooltips and ScreenPositionFixers
* Move modal related components
* Move IdentityProviderLink
* Move GenericAvatar
* Move SizeRating
* Move charts and move deps to peerDeps
* Move nav
* Move formatMeasure
* Move Rating
* Move PageActions
* Move the rest of ui components
* Move more controls components
* Include theme inside extension build
* Add missing theme context provider in extensions
* Update react to same version everywhere
* Update sonar-ui-common
* Update eslint configuration
Diffstat (limited to 'server/sonar-web/src/main/js/helpers/dates.ts')
-rw-r--r-- | server/sonar-web/src/main/js/helpers/dates.ts | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/server/sonar-web/src/main/js/helpers/dates.ts b/server/sonar-web/src/main/js/helpers/dates.ts deleted file mode 100644 index 45b3fc648f0..00000000000 --- a/server/sonar-web/src/main/js/helpers/dates.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import * as _differenceInDays from 'date-fns/difference_in_days'; -import * as _differenceInHours from 'date-fns/difference_in_hours'; -import * as _differenceInSeconds from 'date-fns/difference_in_seconds'; -import * as _differenceInYears from 'date-fns/difference_in_years'; -import * as _isSameDay from 'date-fns/is_same_day'; -import * as _startOfDay from 'date-fns/start_of_day'; -import * as parse from 'date-fns/parse'; - -function pad(number: number) { - if (number < 10) { - return '0' + number; - } - return number; -} - -type ParsableDate = string | number | Date; - -export function parseDate(rawDate: ParsableDate): Date { - return parse(rawDate); -} - -export function toShortNotSoISOString(rawDate: ParsableDate): string { - const date = parseDate(rawDate); - return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`; -} - -export function toNotSoISOString(rawDate: ParsableDate): string { - const date = parseDate(rawDate); - return date.toISOString().replace(/\..+Z$/, '+0000'); -} - -export function startOfDay(date: Date): Date { - return _startOfDay(date); -} - -export function isValidDate(date: Date): boolean { - return !isNaN(date.getTime()); -} - -export function isSameDay(dateLeft: Date, dateRight: Date): boolean { - return _isSameDay(dateLeft, dateRight); -} - -export function differenceInYears(dateLeft: ParsableDate, dateRight: ParsableDate): number { - return _differenceInYears(dateLeft, dateRight); -} - -export function differenceInDays(dateLeft: ParsableDate, dateRight: ParsableDate): number { - return _differenceInDays(dateLeft, dateRight); -} - -export function differenceInHours(dateLeft: ParsableDate, dateRight: ParsableDate): number { - return _differenceInHours(dateLeft, dateRight); -} - -export function differenceInSeconds(dateLeft: ParsableDate, dateRight: ParsableDate): number { - return _differenceInSeconds(dateLeft, dateRight); -} |