Skip to content

Commit

Permalink
Merge branch 'fix/moment' of github.com:jbudz/kibana into fix/moment
Browse files Browse the repository at this point in the history
  • Loading branch information
jbudz committed Mar 3, 2020
2 parents 4bc4111 + c7e412d commit 4d200d1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
8 changes: 2 additions & 6 deletions src/core/public/integrations/moment/moment_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ describe('MomentService', () => {

it('does not set unknkown zone', async () => {
const tz$ = new BehaviorSubject('timezone/undefined');
const dow$ = new BehaviorSubject('dow1');

const uiSettings = uiSettingsServiceMock.createSetupContract();
uiSettings.get$.mockReturnValueOnce(tz$).mockReturnValueOnce(dow$);
uiSettings.get$.mockReturnValueOnce(tz$);

service.start({ uiSettings });
await flushPromises();
Expand All @@ -61,10 +59,8 @@ describe('MomentService', () => {

it('sets timezone when a zone is defined', async () => {
const tz$ = new BehaviorSubject('tz3');
const dow$ = new BehaviorSubject('dow1');

const uiSettings = uiSettingsServiceMock.createSetupContract();
uiSettings.get$.mockReturnValueOnce(tz$).mockReturnValueOnce(dow$);
uiSettings.get$.mockReturnValueOnce(tz$);

service.start({ uiSettings });
await flushPromises();
Expand Down
5 changes: 2 additions & 3 deletions src/core/public/integrations/moment/moment_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import moment from 'moment-timezone';
import { merge, Subscription } from 'rxjs';
import { get } from 'lodash';

import { tap } from 'rxjs/operators';
import { IUiSettingsClient } from '../../ui_settings';
Expand All @@ -37,8 +36,8 @@ export class MomentService implements CoreService {

public async start({ uiSettings }: StartDeps) {
const setDefaultTimezone = (tz: string) => {
const zone: string | undefined = get(moment.tz.zone(tz), 'name');
if (zone) moment.tz.setDefault(zone);
const zone = moment.tz.zone(tz);
if (zone) moment.tz.setDefault(zone.name);
};
const setStartDayOfWeek = (day: string) => {
const dow = moment.weekdays().indexOf(day);
Expand Down

0 comments on commit 4d200d1

Please sign in to comment.