Commit c7c93da9 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'tz-upgrade-dateformat' into 'master'

Updates dateformat to newer version

See merge request gitlab-org/gitlab!63419
parents 744edfc9 92aa80b9
...@@ -26,14 +26,7 @@ const isValidDateString = (dateString) => { ...@@ -26,14 +26,7 @@ const isValidDateString = (dateString) => {
return false; return false;
} }
try { return !Number.isNaN(Date.parse(dateformat(dateString, 'isoUtcDateTime')));
// dateformat throws error that can be caught.
// This is better than using `new Date()`
dateformat(dateString, 'isoUtcDateTime');
return true;
} catch (e) {
return false;
}
}; };
const handleRangeDirection = ({ direction = DEFAULT_DIRECTION, anchorDate, minDate, maxDate }) => { const handleRangeDirection = ({ direction = DEFAULT_DIRECTION, anchorDate, minDate, maxDate }) => {
......
...@@ -106,7 +106,7 @@ export function formatDateAsMonth(datetime, options = {}) { ...@@ -106,7 +106,7 @@ export function formatDateAsMonth(datetime, options = {}) {
/** /**
* @example * @example
* dateFormat('2017-12-05','mmm d, yyyy h:MMtt Z' ) -> "Dec 5, 2017 12:00am GMT+0000" * dateFormat('2017-12-05','mmm d, yyyy h:MMtt Z' ) -> "Dec 5, 2017 12:00am UTC"
* @param {date} datetime * @param {date} datetime
* @param {String} format * @param {String} format
* @param {Boolean} UTC convert local time to UTC * @param {Boolean} UTC convert local time to UTC
......
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`GeoReplicableTimeAgo template when dateString exists TimeAgo sets innerHTML as 09-23-1994 1`] = `"<time title=\\"Sep 23, 1994 12:00am GMT+0000\\" datetime=\\"09-23-1994\\" class=\\"\\">25 years ago</time>"`; exports[`GeoReplicableTimeAgo template when dateString exists TimeAgo sets innerHTML as 09-23-1994 1`] = `"<time title=\\"Sep 23, 1994 12:00am UTC\\" datetime=\\"09-23-1994\\" class=\\"\\">25 years ago</time>"`;
exports[`GeoReplicableTimeAgo template when dateString is null DefaultText sets innerHTML as props.defaultText 1`] = `"<span>Default Text</span>"`; exports[`GeoReplicableTimeAgo template when dateString is null DefaultText sets innerHTML as props.defaultText 1`] = `"<span>Default Text</span>"`;
...@@ -101,7 +101,7 @@ describe('RequirementItem', () => { ...@@ -101,7 +101,7 @@ describe('RequirementItem', () => {
expect(createdAtEl.text()).toContain('created'); expect(createdAtEl.text()).toContain('created');
expect(createdAtEl.text()).toContain('ago'); expect(createdAtEl.text()).toContain('ago');
expect(createdAtEl.attributes('title')).toBe('Mar 19, 2020 8:09am GMT+0000'); expect(createdAtEl.attributes('title')).toBe('Mar 19, 2020 8:09am UTC');
}); });
it('renders element containing requirement author information', () => { it('renders element containing requirement author information', () => {
...@@ -116,7 +116,7 @@ describe('RequirementItem', () => { ...@@ -116,7 +116,7 @@ describe('RequirementItem', () => {
expect(updatedAtEl.text()).toContain('updated'); expect(updatedAtEl.text()).toContain('updated');
expect(updatedAtEl.text()).toContain('ago'); expect(updatedAtEl.text()).toContain('ago');
expect(updatedAtEl.attributes('title')).toBe('Mar 20, 2020 8:09am GMT+0000'); expect(updatedAtEl.attributes('title')).toBe('Mar 20, 2020 8:09am UTC');
}); });
it('renders requirement-status-badge component', () => { it('renders requirement-status-badge component', () => {
......
...@@ -105,7 +105,7 @@ describe('RequirementStatusBadge', () => { ...@@ -105,7 +105,7 @@ describe('RequirementStatusBadge', () => {
expect(tooltipEl.exists()).toBe(true); expect(tooltipEl.exists()).toBe(true);
expect(tooltipEl.find('b').text()).toBe(badgeProps.tooltipTitle); expect(tooltipEl.find('b').text()).toBe(badgeProps.tooltipTitle);
expect(tooltipEl.find('div').text()).toBe('Jun 4, 2020 10:55am GMT+0000'); expect(tooltipEl.find('div').text()).toBe('Jun 4, 2020 10:55am UTC');
}); });
}); });
}); });
......
...@@ -303,7 +303,7 @@ describe('Vulnerability list component', () => { ...@@ -303,7 +303,7 @@ describe('Vulnerability list component', () => {
const { id } = newVulnerabilities[1]; const { id } = newVulnerabilities[1];
const cell = findDataCell(`detected-${id}`); const cell = findDataCell(`detected-${id}`);
expect(cell.text()).toEqual(`2020-07-22`); expect(cell.text()).toEqual(`2020-07-22`);
expect(cell.attributes('title')).toEqual('Jul 22, 2020 7:31pm GMT+0000'); expect(cell.attributes('title')).toEqual('Jul 22, 2020 7:31pm UTC');
}); });
it('should display the vulnerability locations for code', () => { it('should display the vulnerability locations for code', () => {
......
...@@ -336,7 +336,7 @@ describe('IssuableItem', () => { ...@@ -336,7 +336,7 @@ describe('IssuableItem', () => {
const createdAtEl = wrapper.find('[data-testid="issuable-created-at"]'); const createdAtEl = wrapper.find('[data-testid="issuable-created-at"]');
expect(createdAtEl.exists()).toBe(true); expect(createdAtEl.exists()).toBe(true);
expect(createdAtEl.attributes('title')).toBe('Jun 29, 2020 1:52pm GMT+0000'); expect(createdAtEl.attributes('title')).toBe('Jun 29, 2020 1:52pm UTC');
expect(createdAtEl.text()).toBe(wrapper.vm.createdAt); expect(createdAtEl.text()).toBe(wrapper.vm.createdAt);
}); });
...@@ -450,7 +450,7 @@ describe('IssuableItem', () => { ...@@ -450,7 +450,7 @@ describe('IssuableItem', () => {
const updatedAtEl = wrapper.find('[data-testid="issuable-updated-at"]'); const updatedAtEl = wrapper.find('[data-testid="issuable-updated-at"]');
expect(updatedAtEl.exists()).toBe(true); expect(updatedAtEl.exists()).toBe(true);
expect(updatedAtEl.find('span').attributes('title')).toBe('Sep 10, 2020 11:41am GMT+0000'); expect(updatedAtEl.find('span').attributes('title')).toBe('Sep 10, 2020 11:41am UTC');
expect(updatedAtEl.text()).toBe(wrapper.vm.updatedAt); expect(updatedAtEl.text()).toBe(wrapper.vm.updatedAt);
}); });
......
...@@ -64,7 +64,7 @@ describe('JiraImportProgress', () => { ...@@ -64,7 +64,7 @@ describe('JiraImportProgress', () => {
}); });
it('shows the time of import', () => { it('shows the time of import', () => {
expect(getParagraphText()).toContain('Time of import: Apr 8, 2020 12:17pm GMT+0000'); expect(getParagraphText()).toContain('Time of import: Apr 8, 2020 12:17pm UTC');
}); });
it('shows the project key of the import', () => { it('shows the project key of the import', () => {
......
...@@ -101,13 +101,13 @@ describe('Date time utils', () => { ...@@ -101,13 +101,13 @@ describe('Date time utils', () => {
it('should format date properly', () => { it('should format date properly', () => {
const formattedDate = datetimeUtility.formatDate(new Date('07/23/2016')); const formattedDate = datetimeUtility.formatDate(new Date('07/23/2016'));
expect(formattedDate).toBe('Jul 23, 2016 12:00am GMT+0000'); expect(formattedDate).toBe('Jul 23, 2016 12:00am UTC');
}); });
it('should format ISO date properly', () => { it('should format ISO date properly', () => {
const formattedDate = datetimeUtility.formatDate('2016-07-23T00:00:00.559Z'); const formattedDate = datetimeUtility.formatDate('2016-07-23T00:00:00.559Z');
expect(formattedDate).toBe('Jul 23, 2016 12:00am GMT+0000'); expect(formattedDate).toBe('Jul 23, 2016 12:00am UTC');
}); });
it('should throw an error if date is invalid', () => { it('should throw an error if date is invalid', () => {
...@@ -878,7 +878,7 @@ describe('localTimeAgo', () => { ...@@ -878,7 +878,7 @@ describe('localTimeAgo', () => {
it.each` it.each`
timeagoArg | title timeagoArg | title
${false} | ${'some time'} ${false} | ${'some time'}
${true} | ${'Feb 18, 2020 10:22pm GMT+0000'} ${true} | ${'Feb 18, 2020 10:22pm UTC'}
`('converts $seconds seconds to $approximation', ({ timeagoArg, title }) => { `('converts $seconds seconds to $approximation', ({ timeagoArg, title }) => {
const element = document.querySelector('time'); const element = document.querySelector('time');
datetimeUtility.localTimeAgo($(element), timeagoArg); datetimeUtility.localTimeAgo($(element), timeagoArg);
......
...@@ -54,7 +54,7 @@ describe('ExpiresAt', () => { ...@@ -54,7 +54,7 @@ describe('ExpiresAt', () => {
const tooltipDirective = getTooltipDirective(expiredText); const tooltipDirective = getTooltipDirective(expiredText);
expect(tooltipDirective).not.toBeUndefined(); expect(tooltipDirective).not.toBeUndefined();
expect(expiredText.attributes('title')).toBe('Mar 15, 2019 12:00am GMT+0000'); expect(expiredText.attributes('title')).toBe('Mar 15, 2019 12:00am UTC');
}); });
}); });
......
...@@ -208,7 +208,7 @@ describe('Time series component', () => { ...@@ -208,7 +208,7 @@ describe('Time series component', () => {
}); });
it('formats tooltip title', () => { it('formats tooltip title', () => {
expect(wrapper.vm.tooltip.title).toBe('16 Jul 2019, 10:14AM (GMT+0000)'); expect(wrapper.vm.tooltip.title).toBe('16 Jul 2019, 10:14AM (UTC)');
}); });
it('formats tooltip content', () => { it('formats tooltip content', () => {
...@@ -282,7 +282,7 @@ describe('Time series component', () => { ...@@ -282,7 +282,7 @@ describe('Time series component', () => {
}); });
it('formats tooltip title', () => { it('formats tooltip title', () => {
expect(wrapper.vm.tooltip.title).toBe('16 Jul 2019, 10:14AM (GMT+0000)'); expect(wrapper.vm.tooltip.title).toBe('16 Jul 2019, 10:14AM (UTC)');
}); });
it('formats tooltip sha', () => { it('formats tooltip sha', () => {
...@@ -301,7 +301,7 @@ describe('Time series component', () => { ...@@ -301,7 +301,7 @@ describe('Time series component', () => {
}); });
it('formats tooltip title', () => { it('formats tooltip title', () => {
expect(wrapper.vm.tooltip.title).toBe('16 Jul 2019, 10:14AM (GMT+0000)'); expect(wrapper.vm.tooltip.title).toBe('16 Jul 2019, 10:14AM (UTC)');
}); });
it('formats tooltip sha', () => { it('formats tooltip sha', () => {
...@@ -334,7 +334,7 @@ describe('Time series component', () => { ...@@ -334,7 +334,7 @@ describe('Time series component', () => {
it('formats tooltip title and sets tooltip content', () => { it('formats tooltip title and sets tooltip content', () => {
const formattedTooltipData = wrapper.vm.formatAnnotationsTooltipText(mockMarkPoint); const formattedTooltipData = wrapper.vm.formatAnnotationsTooltipText(mockMarkPoint);
expect(formattedTooltipData.title).toBe('19 Feb 2020, 10:01AM (GMT+0000)'); expect(formattedTooltipData.title).toBe('19 Feb 2020, 10:01AM (UTC)');
expect(formattedTooltipData.content).toBe(annotationsMetadata.tooltipData.content); expect(formattedTooltipData.content).toBe(annotationsMetadata.tooltipData.content);
}); });
}); });
......
...@@ -313,10 +313,10 @@ describe('tags list row', () => { ...@@ -313,10 +313,10 @@ describe('tags list row', () => {
}); });
describe.each` describe.each`
name | finderFunction | text | icon | clipboard name | finderFunction | text | icon | clipboard
${'published date detail'} | ${findPublishedDateDetail} | ${'Published to the gitlab-org/gitlab-test/rails-12009 image repository at 01:29 GMT+0000 on 2020-11-03'} | ${'clock'} | ${false} ${'published date detail'} | ${findPublishedDateDetail} | ${'Published to the gitlab-org/gitlab-test/rails-12009 image repository at 01:29 UTC on 2020-11-03'} | ${'clock'} | ${false}
${'manifest detail'} | ${findManifestDetail} | ${'Manifest digest: sha256:2cf3d2fdac1b04a14301d47d51cb88dcd26714c74f91440eeee99ce399089062'} | ${'log'} | ${true} ${'manifest detail'} | ${findManifestDetail} | ${'Manifest digest: sha256:2cf3d2fdac1b04a14301d47d51cb88dcd26714c74f91440eeee99ce399089062'} | ${'log'} | ${true}
${'configuration detail'} | ${findConfigurationDetail} | ${'Configuration digest: sha256:c2613843ab33aabf847965442b13a8b55a56ae28837ce182627c0716eb08c02b'} | ${'cloud-gear'} | ${true} ${'configuration detail'} | ${findConfigurationDetail} | ${'Configuration digest: sha256:c2613843ab33aabf847965442b13a8b55a56ae28837ce182627c0716eb08c02b'} | ${'cloud-gear'} | ${true}
`('$name details row', ({ finderFunction, text, icon, clipboard }) => { `('$name details row', ({ finderFunction, text, icon, clipboard }) => {
it(`has ${text} as text`, async () => { it(`has ${text} as text`, async () => {
mountComponent(); mountComponent();
......
...@@ -35,7 +35,7 @@ describe('User Lists Table', () => { ...@@ -35,7 +35,7 @@ describe('User Lists Table', () => {
it('should set the title for a tooltip on the created stamp', () => { it('should set the title for a tooltip on the created stamp', () => {
expect(wrapper.find('[data-testid="ffUserListTimestamp"]').attributes('title')).toBe( expect(wrapper.find('[data-testid="ffUserListTimestamp"]').attributes('title')).toBe(
'Feb 4, 2020 8:13am GMT+0000', 'Feb 4, 2020 8:13am UTC',
); );
}); });
......
...@@ -94,7 +94,7 @@ describe('MRWidgetPipeline', () => { ...@@ -94,7 +94,7 @@ describe('MRWidgetPipeline', () => {
it('should render pipeline finished timestamp', () => { it('should render pipeline finished timestamp', () => {
expect(findPipelineFinishedAt().attributes()).toMatchObject({ expect(findPipelineFinishedAt().attributes()).toMatchObject({
title: 'Apr 7, 2017 2:00pm GMT+0000', title: 'Apr 7, 2017 2:00pm UTC',
datetime: mockData.pipeline.details.finished_at, datetime: mockData.pipeline.details.finished_at,
}); });
}); });
......
...@@ -18,8 +18,8 @@ describe('MRWidgetClosed', () => { ...@@ -18,8 +18,8 @@ describe('MRWidgetClosed', () => {
avatarUrl: avatarUrl:
'http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', 'http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon',
}, },
mergedAt: 'Jan 24, 2018 1:02pm GMT+0000', mergedAt: 'Jan 24, 2018 1:02pm UTC',
closedAt: 'Jan 24, 2018 1:02pm GMT+0000', closedAt: 'Jan 24, 2018 1:02pm UTC',
readableMergedAt: '', readableMergedAt: '',
readableClosedAt: 'less than a minute ago', readableClosedAt: 'less than a minute ago',
}, },
......
...@@ -37,10 +37,10 @@ describe('MRWidgetMerged', () => { ...@@ -37,10 +37,10 @@ describe('MRWidgetMerged', () => {
avatarUrl: avatarUrl:
'http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', 'http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon',
}, },
mergedAt: 'Jan 24, 2018 1:02pm GMT+0000', mergedAt: 'Jan 24, 2018 1:02pm UTC',
readableMergedAt: '', readableMergedAt: '',
closedBy: {}, closedBy: {},
closedAt: 'Jan 24, 2018 1:02pm GMT+0000', closedAt: 'Jan 24, 2018 1:02pm UTC',
readableClosedAt: '', readableClosedAt: '',
}, },
updatedAt: 'mergedUpdatedAt', updatedAt: 'mergedUpdatedAt',
...@@ -236,6 +236,6 @@ describe('MRWidgetMerged', () => { ...@@ -236,6 +236,6 @@ describe('MRWidgetMerged', () => {
}); });
it('should use mergedEvent mergedAt as tooltip title', () => { it('should use mergedEvent mergedAt as tooltip title', () => {
expect(vm.$el.querySelector('time').getAttribute('title')).toBe('Jan 24, 2018 1:02pm GMT+0000'); expect(vm.$el.querySelector('time').getAttribute('title')).toBe('Jan 24, 2018 1:02pm UTC');
}); });
}); });
...@@ -4169,10 +4169,10 @@ date-now@^0.1.4: ...@@ -4169,10 +4169,10 @@ date-now@^0.1.4:
resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b" resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b"
integrity sha1-6vQ5/U1ISK105cx9vvIAZyueNFs= integrity sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=
dateformat@^3.0.3: dateformat@^4.5.1:
version "3.0.3" version "4.5.1"
resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae" resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-4.5.1.tgz#c20e7a9ca77d147906b6dc2261a8be0a5bd2173c"
integrity sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q== integrity sha512-OD0TZ+B7yP7ZgpJf5K2DIbj3FZvFvxgFUuaqA/V5zTjAtAAXZ1E8bktHxmAGs4x5b7PflqA9LeQ84Og7wYtF7Q==
de-indent@^1.0.2: de-indent@^1.0.2:
version "1.0.2" version "1.0.2"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment