Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Upgrade moment package #1531

Merged
merged 5 commits into from
Mar 8, 2018
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"dragula": "3.7.2",
"intl": "1.2.5",
"microedge-rxstate": "2.0.0",
"moment": "2.18.1",
"moment": "2.21.0",
"ng2-dragula": "1.5.0",
"ng2-toastr": "4.1.2",
"web-animations-js": "2.3.1"
Expand Down
2 changes: 1 addition & 1 deletion src/modules/datepicker/date-formatter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let moment = require('moment');
const moment = require('moment');

export class SkyDateFormatter {
public format(date: Date, format: string): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {

import { By } from '@angular/platform-browser';

let moment = require('moment');
const moment = require('moment');

describe('datepicker calendar', () => {

Expand Down
2 changes: 1 addition & 1 deletion src/modules/datepicker/datepicker-config.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
import { SkyWindowRefService } from '../window';
let moment = require('moment');
const moment = require('moment');
import 'moment/min/locales.min';

@Injectable()
Expand Down
2 changes: 1 addition & 1 deletion src/modules/datepicker/datepicker.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import {By} from '@angular/platform-browser';

import { SkyWindowRefService } from '../window';

let moment = require('moment');
const moment = require('moment');

describe('datepicker', () => {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SkyLinkRecordsStateOrchestrator } from '../link-records-state.rxstate';
import { AsyncItem } from 'microedge-rxstate/dist';
let moment = require('moment');
const moment = require('moment');

import { SkyLinkRecordsFieldModel } from './field.model';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SkyLinkRecordsStateOrchestrator } from '../link-records-state.rxstate';
import { AsyncList } from 'microedge-rxstate/dist';
let moment = require('moment');
const moment = require('moment');

import { SKY_LINK_RECORDS_STATUSES } from '../../link-records-statuses';
import { SkyLinkRecordsMatchModel } from './match.model';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SkyLinkRecordsStateOrchestrator } from '../link-records-state.rxstate';
import { AsyncList } from 'microedge-rxstate/dist';
let moment = require('moment');
const moment = require('moment');

import { SkyLinkRecordsResultModel } from './result.model';
import { SkyLinkRecordsResultsLoadAction } from './actions';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SkyLinkRecordsStateOrchestrator } from '../link-records-state.rxstate';
import { AsyncItem } from 'microedge-rxstate/dist';
let moment = require('moment');
const moment = require('moment');

import {
SkyLinkRecordsSelectedSetSelectedAction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
getData
} from '../list/helpers';

let moment = require('moment');
const moment = require('moment');

export class SkyListInMemoryDataProvider extends ListDataProvider {
public items: BehaviorSubject<Array<ListItemModel>> =
Expand Down
6 changes: 1 addition & 5 deletions src/modules/list-paging/list-paging.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ import { ListItemModel } from '../list/state/items/item.model';

import { AsyncList } from 'microedge-rxstate/dist';

let moment = require('moment');
const moment = require('moment');

describe('List Paging Component', () => {
let state: ListState,
dispatcher: ListStateDispatcher,
component: ListPagingTestComponent,
fixture: any,
nativeElement: HTMLElement,
element: DebugElement;

beforeEach(async(() => {
Expand All @@ -52,9 +50,7 @@ describe('List Paging Component', () => {
});

fixture = TestBed.createComponent(ListPagingTestComponent);
nativeElement = fixture.nativeElement as HTMLElement;
element = fixture.debugElement as DebugElement;
component = fixture.componentInstance;
fixture.detectChanges();

// always skip the first update to ListState, when state is ready
Expand Down
2 changes: 1 addition & 1 deletion src/modules/list-toolbar/list-toolbar-item.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Input, ContentChildren, TemplateRef, QueryList } from '@angular/core';
let moment = require('moment');
const moment = require('moment');

@Component({
selector: 'sky-list-toolbar-item',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
ListState,
ListStateDispatcher
} from '../list/state';
let moment = require('moment');
const moment = require('moment');
import { ListViewsLoadAction } from '../list/state/views/actions';
import { ListViewModel } from '../list/state/views/view.model';
import { ListItemModel } from '../list/state/items/item.model';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
ListViewChecklistItemsLoadAction
} from './actions';

let moment = require('moment');
const moment = require('moment');

export class ListViewChecklistItemsOrchestrator
extends ChecklistStateOrchestrator<AsyncList<ListViewChecklistItemModel>> {
Expand Down
3 changes: 2 additions & 1 deletion src/modules/list-view-grid/list-view-grid.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
ListState,
ListStateDispatcher
} from '../list/state';
let moment = require('moment');

const moment = require('moment');

import {
ListViewsLoadAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AsyncList } from 'microedge-rxstate/dist';
import { SkyGridColumnModel } from '../../../grid';
import { ListViewGridColumnsLoadAction } from './actions';

let moment = require('moment');
const moment = require('moment');

export class ListViewGridColumnsOrchestrator
extends GridStateOrchestrator<AsyncList<SkyGridColumnModel>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AsyncList } from 'microedge-rxstate/dist';
import { SkyGridColumnModel } from '../../../grid';
import { ListViewDisplayedGridColumnsLoadAction } from './actions';

let moment = require('moment');
const moment = require('moment');

export class ListViewDisplayedGridColumnsOrchestrator
extends GridStateOrchestrator<AsyncList<SkyGridColumnModel>> {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/list/list.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
ListState,
ListStateDispatcher
} from '../list/state';
let moment = require('moment');
const moment = require('moment');
import { Observable } from 'rxjs/Observable';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';

Expand Down
3 changes: 2 additions & 1 deletion src/modules/list/list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ import { ListItemModel } from './state/items/item.model';
import {
isObservable
} from './helpers';
let moment = require('moment');

const moment = require('moment');

@Component({
selector: 'sky-list',
Expand Down
2 changes: 1 addition & 1 deletion src/modules/list/state/items/items.orchestrator.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ListStateOrchestrator } from '../list-state.rxstate';
import { AsyncList } from 'microedge-rxstate/dist';

let moment = require('moment');
const moment = require('moment');

import { ListItemModel } from './item.model';
import {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/list/state/selected/selected.orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
ListSelectedSetItemsSelectedAction
} from './actions';

let moment = require('moment');
const moment = require('moment');

export class ListSelectedOrchestrator extends ListStateOrchestrator<AsyncItem<ListSelectedModel>> {
/* istanbul ignore next */
Expand Down
2 changes: 1 addition & 1 deletion src/modules/timepicker/timepicker-component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { TimepickerTestComponent } from './fixtures/timepicker-component.fixture

import { expect } from '../testing';

let moment = require('moment');
const moment = require('moment');

describe('Timepicker', () => {
function openTimepicker(element: HTMLElement, compFixture: ComponentFixture<any>) {
Expand Down
24 changes: 12 additions & 12 deletions src/modules/timepicker/timepicker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {

import { SkyTimepickerTimeOutput } from './timepicker.interface';

let moment = require('moment');
const moment = require('moment');

@Component({
selector: 'sky-timepicker',
Expand Down Expand Up @@ -101,7 +101,7 @@ export class SkyTimepickerComponent implements OnInit {
hour: moment(this.activeTime).hour(),
minute: moment(this.activeTime).minute(),
meridie: moment(this.activeTime).format('A'),
timezone: moment(this.activeTime).format('Z'),
timezone: parseInt(moment(this.activeTime).format('Z'), 10),
iso8601: this.activeTime,
local: moment(this.activeTime).format(this.localeFormat),
customFormat: (typeof this.returnFormat !== 'undefined')
Expand Down Expand Up @@ -136,7 +136,7 @@ export class SkyTimepickerComponent implements OnInit {
});
}

private set selectedHour(setHour: number) {
public set selectedHour(setHour: number) {
let hour: number;
let hourOffset: number = 0;
if (this.selectedMeridies === 'AM' && setHour === 12) { hourOffset = -12; }
Expand All @@ -147,29 +147,29 @@ export class SkyTimepickerComponent implements OnInit {
this.activeTime = moment({
'hour': hour,
'minute': moment(this.activeTime).get('minute') + 0
}).format();
}).toDate();
this.selectedTimeChanged.emit(this.selectedTime);
}

private set selectedMinute(minute: number) {
public set selectedMinute(minute: number) {
this.activeTime = moment({
'hour': moment(this.activeTime).get('hour') + 0,
'minute': minute
}).format();
}).toDate();
this.selectedTimeChanged.emit(this.selectedTime);
}

private set selectedMeridies(meridies: string) {
public set selectedMeridies(meridies: string) {
/* istanbul ignore else */
if (!this.is8601) {
if (meridies !== this.selectedMeridies) {
this.activeTime = moment(this.activeTime).add(12, 'hours').format();
this.activeTime = moment(this.activeTime).add(12, 'hours').toDate();
this.selectedTimeChanged.emit(this.selectedTime);
}
}
}

private get selectedHour() {
public get selectedHour() {
if (!this.is8601) {
/* istanbul ignore next */
return parseInt(moment(this.activeTime).format('h'), 0) || 1;
Expand All @@ -178,13 +178,13 @@ export class SkyTimepickerComponent implements OnInit {
if (this.is8601) {
return moment(this.activeTime).hour() + 0;
}

}
private get selectedMinute() {

public get selectedMinute() {
return moment(this.activeTime).minute() + 0;
}

private get selectedMeridies() {
public get selectedMeridies() {
if (this.activeTime) {
return moment(this.activeTime).format('A');
}
Expand Down
6 changes: 3 additions & 3 deletions src/modules/timepicker/timepicker.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
OnChanges,
SimpleChanges
} from '@angular/core';
let moment = require('moment');
const moment = require('moment');
import {
SkyTimepickerComponent
} from './timepicker.component';
Expand Down Expand Up @@ -152,8 +152,8 @@ export class SkyTimepickerInputDirective implements
'hour': moment(time, currentFormat).hour(),
'minute': moment(time, currentFormat).minute(),
'meridie': moment(time, currentFormat).format('A'),
'timezone': moment(time, currentFormat).format('Z'),
'iso8601': moment(time, currentFormat).format(),
'timezone': parseInt(moment(time, currentFormat).format('Z'), 10),
'iso8601': moment(time, currentFormat).toDate(),
'local': moment(time, currentFormat).format(currentFormat),
'customFormat': this.returnFormat
};
Expand Down