Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1727,7 +1727,6 @@
"cypress-network-idle": "^1.14.2",
"cypress-real-events": "^1.11.0",
"cypress-recurse": "^1.35.2",
"date-fns": "^2.29.3",
"dependency-check": "^4.1.0",
"dependency-cruiser": "^16.8.0",
"ejs": "^3.1.10",
Expand Down
1 change: 0 additions & 1 deletion packages/kbn-babel-register/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ BUNDLER_DEPS = [
"@npm//chalk",
"@npm//pirates",
"@npm//lmdb",
"@npm//date-fns",
"@npm//source-map-support",
"//src/platform/packages/private/kbn-repo-packages",
"//src/platform/packages/shared/kbn-repo-info",
Expand Down
5 changes: 1 addition & 4 deletions packages/kbn-babel-register/cache/lmdb_cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@

const Path = require('path');
const Crypto = require('crypto');
const startOfDay = /** @type {import('date-fns/startOfDay').default} */ (
/** @type {unknown} */ (require('date-fns/startOfDay'))
);

const chalk = require('chalk');
const LmdbStore = require('lmdb');

const GLOBAL_ATIME = startOfDay(new Date()).valueOf();
const GLOBAL_ATIME = new Date().setHours(0, 0, 0, 0);
const MINUTE = 1000 * 60;
const HOUR = MINUTE * 60;
const DAY = HOUR * 24;
Expand Down
20 changes: 0 additions & 20 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -3478,26 +3478,6 @@
"minimumReleaseAge": "7 days",
"enabled": true
},
{
"groupName": "date-fns",
"matchDepNames": [
"date-fns"
],
"reviewers": [
"team:obs-ux-management-team"
],
"matchBaseBranches": [
"main"
],
"labels": [
"release_note:skip",
"backport:all-open",
"ci:all-cypress-suites",
"Team:obs-ux-management"
],
"minimumReleaseAge": "7 days",
"enabled": true
},
{
"groupName": "form-data",
"matchDepNames": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import { identity, range } from 'lodash';
import * as Rx from 'rxjs';
import type { Writable } from 'stream';
import { add, type Duration } from 'date-fns';

import { errors as esErrors, estypes } from '@elastic/elasticsearch';
import type { SearchResponse } from '@elastic/elasticsearch/lib/api/types';
Expand Down Expand Up @@ -38,6 +37,7 @@ import {
UI_SETTINGS_DATEFORMAT_TZ,
} from '../constants';
import { CsvGenerator } from './generate_csv';
import moment from 'moment';

type CsvConfigType = ReportingConfigType['csv'];

Expand Down Expand Up @@ -576,9 +576,9 @@ describe('CsvGenerator', () => {
});

describe('export behavior when scroll duration config is auto', () => {
const getTaskInstanceFields = (intervalFromNow: Duration) => {
const getTaskInstanceFields = (intervalFromNow: { seconds: number }) => {
const now = new Date(Date.now());
return { startedAt: now, retryAt: add(now, intervalFromNow) };
return { startedAt: now, retryAt: moment(now).add(intervalFromNow).toDate() };
};

let mockConfigWithAutoScrollDuration: ReportingConfigType['csv'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import * as Rx from 'rxjs';
import type { Writable } from 'stream';
import { add, type Duration } from 'date-fns';

import { errors as esErrors } from '@elastic/elasticsearch';
import type { IScopedClusterClient, IUiSettingsClient, Logger } from '@kbn/core/server';
Expand All @@ -31,6 +30,7 @@ import {
UI_SETTINGS_DATEFORMAT_TZ,
} from '../constants';
import { CsvESQLGenerator, JobParamsCsvESQL } from './generate_csv_esql';
import moment from 'moment';

const createMockJob = (params: JobParamsCsvESQL): JobParamsCsvESQL => ({
...params,
Expand Down Expand Up @@ -216,9 +216,9 @@ describe('CsvESQLGenerator', () => {
});

describe('"auto" scroll duration config', () => {
const getTaskInstanceFields = (intervalFromNow: Duration) => {
const getTaskInstanceFields = (intervalFromNow: { seconds: number }) => {
const now = new Date(Date.now());
return { startedAt: now, retryAt: add(now, intervalFromNow) };
return { startedAt: now, retryAt: moment(now).add(intervalFromNow).toDate() };
};

let mockConfigWithAutoScrollDuration: ReportingConfigType['csv'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
} from '@kbn/core/server/mocks';
import type { ReportingConfigType } from '@kbn/reporting-server';
import type { TaskInstanceFields } from '@kbn/reporting-common/types';
import { sub, add, type Duration } from 'date-fns';

import {
UI_SETTINGS_CSV_QUOTE_VALUES,
Expand All @@ -24,6 +23,7 @@ import {
UI_SETTINGS_SEARCH_INCLUDE_FROZEN,
} from '../../constants';
import { getExportSettings } from './get_export_settings';
import moment from 'moment';

describe('getExportSettings', () => {
let uiSettingsClient: IUiSettingsClient;
Expand Down Expand Up @@ -154,7 +154,7 @@ describe('getExportSettings', () => {
describe('scroll duration function', () => {
let spiedDateNow: jest.Spied<typeof Date.now>;
let mockedTaskInstanceFields: TaskInstanceFields;
const durationApart: Duration = { minutes: 5 };
const durationApart: { minutes: number } = { minutes: 5 };

beforeEach(() => {
const now = Date.now();
Expand All @@ -163,8 +163,8 @@ describe('getExportSettings', () => {
spiedDateNow = jest.spyOn(Date, 'now').mockReturnValue(now);

mockedTaskInstanceFields = {
startedAt: sub(new Date(Date.now()), durationApart),
retryAt: add(new Date(Date.now()), durationApart),
startedAt: moment().subtract(durationApart).toDate(),
retryAt: moment().add(durationApart).toDate(),
};
});

Expand Down Expand Up @@ -238,7 +238,7 @@ describe('getExportSettings', () => {
};

spiedDateNow.mockReturnValue(
add(mockedTaskInstanceFields.retryAt!, { minutes: 5 }).getTime()
moment(mockedTaskInstanceFields.retryAt!).add(durationApart).toDate().getTime()
);

const { scroll } = await getExportSettings(
Expand Down
8 changes: 4 additions & 4 deletions test/api_integration/apis/home/sample_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

import expect from '@kbn/expect';
import type { Response } from 'superagent';
import differenceInMilliseconds from 'date-fns/differenceInMilliseconds';
import { X_ELASTIC_INTERNAL_ORIGIN_REQUEST } from '@kbn/core-http-common';
import moment from 'moment';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService }: FtrProviderContext) {
Expand Down Expand Up @@ -75,9 +75,9 @@ export default function ({ getService }: FtrProviderContext) {
describe('dates', () => {
// dates being compared are not arbitrary, but rather the dates of the earliest and latest timestamp of the flight sample data
// this can be verified in the flight data archive here {@link src/platform/plugins/shared/home/server/services/sample_data/data_sets/flights/flights.json.gz}
const sampleDataTimeIntervalInMS = differenceInMilliseconds(
new Date('2018-02-11T14:54:34'),
new Date('2018-01-01T00:00:00')
const sampleDataTimeIntervalInMS = moment('2018-02-11T14:54:34').diff(
moment('2018-01-01T00:00:00'),
'milliseconds'
);

it('should load elasticsearch index containing sample data with dates relative to current time', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@

import { EuiFlexGroup, EuiFlexItem, EuiText } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
// eslint-disable-next-line import/no-extraneous-dependencies
import { formatDistance } from 'date-fns';
import React from 'react';
import moment from 'moment';
import { InvestigationStatusBadge } from '../../../../components/investigation_status_badge/investigation_status_badge';
import { InvestigationTag } from '../../../../components/investigation_tag/investigation_tag';
import { useInvestigation } from '../../contexts/investigation_context';
Expand Down Expand Up @@ -52,13 +51,7 @@ export function InvestigationHeader() {
id="xpack.investigateApp.investigationHeader.startedLabel"
defaultMessage="Started: {timeAgo}"
values={{
timeAgo: (
<strong>
{formatDistance(new Date(investigation.createdAt), new Date(), {
addSuffix: true,
})}
</strong>
),
timeAgo: <strong>{moment(investigation.createdAt).fromNow()}</strong>,
}}
/>
</EuiText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ import {
import { css } from '@emotion/css';
import { InvestigationNoteResponse } from '@kbn/investigation-shared';
import { UserProfile } from '@kbn/security-plugin/common';
// eslint-disable-next-line import/no-extraneous-dependencies
import { formatDistance } from 'date-fns';
import React, { useState } from 'react';
import moment from 'moment';
import { useTheme } from '../../../../hooks/use_theme';
import { useInvestigation } from '../../contexts/investigation_context';
import { EditNoteForm } from './edit_note_form';
Expand Down Expand Up @@ -78,7 +77,7 @@ export function Note({ note, isOwner, userProfile, userProfileLoading }: Props)
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiText size="xs" className={timestampClassName}>
{formatDistance(new Date(note.createdAt), new Date(), { addSuffix: true })}
{moment(new Date(note.createdAt)).fromNow()}
</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16869,11 +16869,6 @@ date-fns@^1.30.1:
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-1.30.1.tgz#2e71bf0b119153dbb4cc4e88d9ea5acfb50dc05c"
integrity sha512-hBSVCvSmWC+QypYObzwGOd9wqdDpOt+0wl0KbU+R+uuZBS1jN8VsD1ss3irQDknRj5NvxiTF6oj/nDRnN/UQNw==

date-fns@^2.29.3:
version "2.29.3"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.29.3.tgz#27402d2fc67eb442b511b70bbdf98e6411cd68a8"
integrity sha512-dDCnyH2WnnKusqvZZ6+jA1O51Ibt8ZMRNkDZdyAyK4YfbDwa/cEmuztzG5pk6hqlp9aSBPYcjOlktquahGwGeA==

date-now@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b"
Expand Down