From 8a08378a7f4e40d4185bb163326707b896433023 Mon Sep 17 00:00:00 2001 From: Andrew Cherniavskii Date: Thu, 5 Apr 2018 13:44:09 +0200 Subject: [PATCH 01/18] [docs] remove vertical scrollbar --- docs/src/layout/Layout.jsx | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/src/layout/Layout.jsx b/docs/src/layout/Layout.jsx index 5c11209e3..2609b1be6 100644 --- a/docs/src/layout/Layout.jsx +++ b/docs/src/layout/Layout.jsx @@ -163,7 +163,6 @@ const styles = theme => ({ }, landingMain: { padding: 0, - width: '100vw', maxWidth: '100vw', marginLeft: 0, }, From c1daddf16a899f954aec14ad1d17f8640a7899c3 Mon Sep 17 00:00:00 2001 From: Dmitriy Kovalenko Date: Sat, 7 Apr 2018 16:40:46 +0300 Subject: [PATCH 02/18] Update PULL_REQUEST_TEMPLATE.md --- PULL_REQUEST_TEMPLATE.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md index 138d35eb9..35b56fd7f 100644 --- a/PULL_REQUEST_TEMPLATE.md +++ b/PULL_REQUEST_TEMPLATE.md @@ -1,8 +1,9 @@ -- [ ] I have changed my target branch to **develop** :facepunch: + +- [] I have changed my target branch to **develop** :facepunch: -# +### Issue # ## Description From 8f0b40b658f65e1d23a48111945b007b0c0f4c2a Mon Sep 17 00:00:00 2001 From: Dmitriy Kovalenko Date: Sat, 7 Apr 2018 16:41:19 +0300 Subject: [PATCH 03/18] Update PULL_REQUEST_TEMPLATE.md --- PULL_REQUEST_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md index 35b56fd7f..166cf59cc 100644 --- a/PULL_REQUEST_TEMPLATE.md +++ b/PULL_REQUEST_TEMPLATE.md @@ -2,7 +2,7 @@ -- [] I have changed my target branch to **develop** :facepunch: +- [ ] I have changed my target branch to **develop** :facepunch: ### Issue # From edcf3ba6144e12af6cc89ec798d888e914fd2905 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 9 Apr 2018 18:55:27 +0200 Subject: [PATCH 04/18] wip for luxon support --- lib/__tests__/test-utils.d.ts | 3 +- lib/__tests__/test-utils.js | 18 +++- lib/__tests__/utils/luxon-utils.test.js | 136 ++++++++++++++++++++++++ lib/package.json | 3 + lib/src/utils/luxon-utils.d.ts | 55 ++++++++++ lib/src/utils/luxon-utils.js | 89 ++++++++++++++++ 6 files changed, 300 insertions(+), 4 deletions(-) create mode 100644 lib/__tests__/utils/luxon-utils.test.js create mode 100644 lib/src/utils/luxon-utils.d.ts create mode 100644 lib/src/utils/luxon-utils.js diff --git a/lib/__tests__/test-utils.d.ts b/lib/__tests__/test-utils.d.ts index 8c0407b73..b5a9d402d 100644 --- a/lib/__tests__/test-utils.d.ts +++ b/lib/__tests__/test-utils.d.ts @@ -1,4 +1,5 @@ import MomentUtils from '../src/utils/moment-utils' import DateFnsUtils from '../src/utils/date-fns-utils' +import LuxonUtils from '../src/utils/luxon-utils'; -export const utilsToUse: typeof MomentUtils | typeof DateFnsUtils; \ No newline at end of file +export const utilsToUse: typeof MomentUtils | typeof DateFnsUtils | typeof LuxonUtils; \ No newline at end of file diff --git a/lib/__tests__/test-utils.js b/lib/__tests__/test-utils.js index f933b64d5..6fb8f60d4 100644 --- a/lib/__tests__/test-utils.js +++ b/lib/__tests__/test-utils.js @@ -2,10 +2,22 @@ import React from 'react'; import * as enzyme from 'enzyme'; import DateFnsUtils from '../src/utils/date-fns-utils'; import MomentUtils from '../src/utils/moment-utils'; +import LuxonUtils from '../src/utils/luxon-utils'; -export const utilsToUse = process.env.UTILS === 'moment' - ? new MomentUtils() - : new DateFnsUtils(); +const getUtilToUse = () => { + switch (process.env.UTILS) { + case 'moment': + return new MomentUtils(); + case 'date-fns': + return new DateFnsUtils(); + case 'luxon': + return new LuxonUtils(); + default: + return new LuxonUtils(); + } +}; + +export const utilsToUse = getUtilToUse(); const getComponentWithUtils = Component => React.cloneElement(Component, { utils: utilsToUse }); diff --git a/lib/__tests__/utils/luxon-utils.test.js b/lib/__tests__/utils/luxon-utils.test.js new file mode 100644 index 000000000..df5e30e13 --- /dev/null +++ b/lib/__tests__/utils/luxon-utils.test.js @@ -0,0 +1,136 @@ +import LuxonUtils from '../../src/utils/luxon-utils'; + +describe('Luxon utils', () => { + let luxonUtil; + + beforeEach(() => { + luxonUtil = new LuxonUtils(); + }); + + it('Should return a Luxon DateTime instance', () => { + const now = luxonUtil.date(); + const nowJs = luxonUtil.date(new Date()); + expect(now.constructor.name).toBe('DateTime'); + expect(nowJs.constructor.name).toBe('DateTime'); + }); + + it('Should add one day', () => { + const now = luxonUtil.date(); + const then = luxonUtil.addDays(now, 1); + const thenPast = luxonUtil.addDays(now, -1); + + expect(then).toEqual(now.plus({ day: 1 })); + expect(thenPast).toEqual(now.minus({ day: 1 })); + }); + + it('Should be a valid DateTime', () => { + const now = luxonUtil.date(); + + expect(luxonUtil.isValid(now)).toBe(true); + }); + + it('Should be equal to another DateTime', () => { + const now = luxonUtil.date(); + const then = now.plus({ day: 1 }); + + expect(luxonUtil.isEqual(now, now)).toBe(true); + expect(luxonUtil.isEqual(now, then)).toBe(false); + }); + + it('Should be on the same day', () => { + const now = luxonUtil.date(); + const then = now.plus({ hours: 1 }); + const thenOtherDay = now.plus({ days: 1 }); + + expect(luxonUtil.isSameDay(now, then)).toBe(true); + expect(luxonUtil.isSameDay(now, thenOtherDay)).toBe(false); + }); + + it('Should check if one date is after another', () => { + const now = luxonUtil.date(); + const then = now.plus({ day: 1 }); + + expect(luxonUtil.isAfter(now, then)).toBe(false); + expect(luxonUtil.isAfter(then, now)).toBe(true); + }); + + it('Should check if it is the day after', () => { + const now = luxonUtil.date(); + const then = now.plus({ day: 1 }); + + expect(luxonUtil.isAfterDay(now, then)).toBe(false); + expect(luxonUtil.isAfterDay(then, now)).toBe(true); + }); + + it('Should check if it is the year after', () => { + const now = luxonUtil.date(); + const then = now.plus({ years: 1 }); + + expect(luxonUtil.isAfterYear(now, then)).toBe(false); + expect(luxonUtil.isAfterYear(then, now)).toBe(true); + }); + + it('Should check if one date is before another', () => { + const now = luxonUtil.date(); + const then = now.minus({ day: 1 }); + + expect(luxonUtil.isBefore(now, then)).toBe(false); + expect(luxonUtil.isBefore(then, now)).toBe(true); + }); + + it('Should check if it is the day before', () => { + const now = luxonUtil.date(); + const then = now.minus({ day: 1 }); + + expect(luxonUtil.isBeforeDay(now, then)).toBe(false); + expect(luxonUtil.isBeforeDay(then, now)).toBe(true); + }); + + it('Should check if it is the year before', () => { + const now = luxonUtil.date(); + const then = now.minus({ years: 1 }); + + expect(luxonUtil.isBeforeYear(now, then)).toBe(false); + expect(luxonUtil.isBeforeYear(then, now)).toBe(true); + }); + + it('Should be the start of the day', () => { + const now = luxonUtil.date(new Date(2018, 0, 1, 1)); + const startDay = luxonUtil.date(new Date(2018, 0)); + + expect(luxonUtil.startOfDay(now)).toEqual(startDay); + }); + + it('Should be the end of the day', () => { + const now = luxonUtil.date(new Date(2018, 0)); + const endDay = luxonUtil.date(new Date(2018, 0, 1, 23, 59, 59, 999)); + + expect(luxonUtil.endOfDay(now)).toEqual(endDay); + }); + + it('Should format correctly', () => { + const now = luxonUtil.date(new Date(2018, 0)); + + expect(luxonUtil.format(now, 'yyyy LLL dd')).toBe('2018 Jan 01'); + }); + + it('Should format numbers correclty', () => { + const number = 23; + + expect(luxonUtil.formatNumber(number)).toBe('23'); + }); + + it('Should get the hours', () => { + const now = luxonUtil.date(new Date(2018, 0)); + + expect(luxonUtil.getHours(now)).toBe(0); + }); + + it('Should check if null', () => { + const now = luxonUtil.date(); + + expect(luxonUtil.isNull(null)).toBe(true); + expect(luxonUtil.isNull(now)).toBe(false); + }); +}); + diff --git a/lib/package.json b/lib/package.json index df497f545..0d416f782 100644 --- a/lib/package.json +++ b/lib/package.json @@ -44,6 +44,7 @@ }, "dependencies": { "babel-runtime": "^6.26.0", + "luxon": "^1.0.0", "react-text-mask": "^5.1.0" }, "scripts": { @@ -69,7 +70,9 @@ }, "devDependencies": { "@types/classnames": "^2.2.3", + "@types/jest": "^22.2.2", "@types/jss": "^9.3.0", + "@types/luxon": "^0.5.0", "@types/moment": "^2.13.0", "@types/prop-types": "^15.5.2", "@types/react": "^16.0.39", diff --git a/lib/src/utils/luxon-utils.d.ts b/lib/src/utils/luxon-utils.d.ts new file mode 100644 index 000000000..ba495cca6 --- /dev/null +++ b/lib/src/utils/luxon-utils.d.ts @@ -0,0 +1,55 @@ +import { DateTime } from 'luxon'; +import { Utils } from '../typings/utils' + +declare class LuxonUtils extends Utils { + locale: any; + constructor (options?: { locale: any }); + + date(value: any): DateTime; + addDays(value: DateTime, count: number): DateTime; + isValid(value: DateTime): boolean; + isEqual(value: DateTime, comparing: DateTime): boolean; + isSameDay(value: DateTime, comparing: DateTime): boolean + + isAfter(value: DateTime, comparing: DateTime): boolean; + isAfterDay(value: DateTime, comparing: DateTime): boolean; + isAfterYear(value: DateTime, comparing: DateTime): boolean; + + isBeforeDay(value: DateTime, comparing: DateTime): boolean; + isBeforeYear(value: DateTime, comparing: DateTime): boolean; + isBefore(value: DateTime, comparing: DateTime): boolean; + + startOfDay(value: DateTime): DateTime; + endOfDay(value: DateTime): DateTime; + + format(value: DateTime, formatString: string): string; + formatNumber(number: number): string; + + getHours(value: DateTime): number; + setHours(value: DateTime, count: number): DateTime; + getMinutes(value: DateTime): number; + setMinutes(value: DateTime, count: number): DateTime + getMonth(value: DateTime): number; + getYear(value: DateTime): number; + setYear(value: DateTime): DateTime; + + getStartOfMonth(value: DateTime): DateTime; + getNextMonth(value: DateTime): DateTime; + getPreviousMonth(value: DateTime): DateTime; + + getWeekdays(): string[]; + getWeekArray(): DateTime[]; + getYearRange(): DateTime[]; + + // displaying methods + getMeridiemText(ampm: 'am' | 'pm'): string; + getCalendarHeaderText(date: DateTime): string; + getDateTimePickerHeaderText(date: DateTime): string; + getDateTimePickerHeaderText(date: DateTime): string; + getDayText(date: DateTime): string; + getHourText(date: DateTime, ampm: boolean): string; + getMinuteText(date: DateTime): string; + getYearText(date: DateTime): string; +} + +export default LuxonUtils; diff --git a/lib/src/utils/luxon-utils.js b/lib/src/utils/luxon-utils.js new file mode 100644 index 000000000..ff53fd4db --- /dev/null +++ b/lib/src/utils/luxon-utils.js @@ -0,0 +1,89 @@ +import { DateTime } from 'luxon'; + +export default class LuxonUtils { + parse = DateTime.fromFormat; + + constructor({ locale } = {}) { + this.locale = locale; + } + + date(value) { + if (typeof value === 'undefined') { + return DateTime.local(); + } + + return DateTime.fromJSDate(value); + } + + addDays(date, count) { + if (count < 0) { + return date.minus({ days: Math.abs(count) }); + } + + return date.plus({ days: count }); + } + + isValid(date) { + return date.isValid; + } + + isEqual(value, comparing) { + return value === comparing; + } + + isSameDay(value, comparing) { + return value.hasSame(comparing, 'day'); + } + + isAfter(value, comparing) { + return value > comparing; + } + + isAfterDay(value, comparing) { + const diff = value.diff(comparing, 'days').toObject(); + return diff.days > 0; + } + + isAfterYear(value, comparing) { + const diff = value.diff(comparing, 'years').toObject(); + return diff.years > 0; + } + + isBefore(value, comparing) { + return value < comparing; + } + + isBeforeDay(value, comparing) { + const diff = value.diff(comparing, 'days').toObject(); + return diff.days < 0; + } + + isBeforeYear(value, comparing) { + const diff = value.diff(comparing, 'years').toObject(); + return diff.years < 0; + } + + startOfDay(value) { + return value.startOf('day'); + } + + endOfDay(value) { + return value.endOf('day'); + } + + format(date, format) { + return date.toFormat(format); + } + + formatNumber(number) { + return String(number); + } + + getHours(value) { + return value.get('hour'); + } + + isNull(date) { + return date === null; + } +} From 9a3e8b7a4e14eac5feca01ce2c5a1dd7d5dddcf9 Mon Sep 17 00:00:00 2001 From: lookapanda Date: Mon, 9 Apr 2018 20:04:34 +0200 Subject: [PATCH 05/18] Fix missing argument in typings setYear is missing the second argument --- lib/src/typings/utils.d.ts | 2 +- lib/src/utils/date-fns-utils.d.ts | 2 +- lib/src/utils/moment-utils.d.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/typings/utils.d.ts b/lib/src/typings/utils.d.ts index 225dd5bac..9190e6a7e 100644 --- a/lib/src/typings/utils.d.ts +++ b/lib/src/typings/utils.d.ts @@ -30,7 +30,7 @@ export class Utils { setMinutes(value: MaterialUiPickersDate, count: number): MaterialUiPickersDate getMonth(value: MaterialUiPickersDate): number; getYear(value: MaterialUiPickersDate): number; - setYear(value: MaterialUiPickersDate): MaterialUiPickersDate; + setYear(value: MaterialUiPickersDate, year: number): MaterialUiPickersDate; getStartOfMonth(value: MaterialUiPickersDate): MaterialUiPickersDate; getNextMonth(value: MaterialUiPickersDate): MaterialUiPickersDate; diff --git a/lib/src/utils/date-fns-utils.d.ts b/lib/src/utils/date-fns-utils.d.ts index 8e99cfb28..5d185948d 100644 --- a/lib/src/utils/date-fns-utils.d.ts +++ b/lib/src/utils/date-fns-utils.d.ts @@ -30,7 +30,7 @@ declare class DateFnsUtils extends Utils { setMinutes(value: Date, count: number): Date getMonth(value: Date): number; getYear(value: Date): number; - setYear(value: Date): Date; + setYear(value: Date, year: number): Date; getStartOfMonth(value: Date): Date; getNextMonth(value: Date): Date; diff --git a/lib/src/utils/moment-utils.d.ts b/lib/src/utils/moment-utils.d.ts index 31a26fcbf..72e85e997 100644 --- a/lib/src/utils/moment-utils.d.ts +++ b/lib/src/utils/moment-utils.d.ts @@ -31,7 +31,7 @@ declare class MomentUtils extends Utils { setMinutes(value: Moment, count: number): Moment getMonth(value: Moment): number; getYear(value: Moment): number; - setYear(value: Moment): Moment; + setYear(value: Moment, year: number): Moment; getStartOfMonth(value: Moment): Moment; getNextMonth(value: Moment): Moment; From 0b54571defa976a6b5860846dda5def1eca8896e Mon Sep 17 00:00:00 2001 From: lookapanda Date: Mon, 9 Apr 2018 20:08:26 +0200 Subject: [PATCH 06/18] More typings --- lib/__tests__/test-utils.js | 2 +- lib/__tests__/utils/luxon-utils.test.js | 39 +++++++++++++++++++++++++ lib/src/utils/luxon-utils.d.ts | 2 +- lib/src/utils/luxon-utils.js | 25 ++++++++++++++++ 4 files changed, 66 insertions(+), 2 deletions(-) diff --git a/lib/__tests__/test-utils.js b/lib/__tests__/test-utils.js index 6fb8f60d4..d9c2045d3 100644 --- a/lib/__tests__/test-utils.js +++ b/lib/__tests__/test-utils.js @@ -13,7 +13,7 @@ const getUtilToUse = () => { case 'luxon': return new LuxonUtils(); default: - return new LuxonUtils(); + return new DateFnsUtils(); } }; diff --git a/lib/__tests__/utils/luxon-utils.test.js b/lib/__tests__/utils/luxon-utils.test.js index df5e30e13..3c634b266 100644 --- a/lib/__tests__/utils/luxon-utils.test.js +++ b/lib/__tests__/utils/luxon-utils.test.js @@ -126,6 +126,45 @@ describe('Luxon utils', () => { expect(luxonUtil.getHours(now)).toBe(0); }); + it('Should set hours', () => { + const now = luxonUtil.date(new Date(2018, 0)); + const plusOneHour = now.plus({ hours: 1 }); + + expect(luxonUtil.setHours(now, 1)).toEqual(plusOneHour); + }); + + it('Should get the minutes', () => { + const now = luxonUtil.date(new Date(2018, 0)); + + expect(luxonUtil.getMinutes(now)).toBe(0); + }); + + it('Should set minutes', () => { + const now = luxonUtil.date(new Date(2018, 0)); + const plusOneMinute = now.plus({ minutes: 1 }); + + expect(luxonUtil.setMinutes(now, 1)).toEqual(plusOneMinute); + }); + + it('Should get the month', () => { + const now = luxonUtil.date(new Date(2018, 0)); + + expect(luxonUtil.getMonth(now)).toBe(0); + }); + + it('Should get the year', () => { + const now = luxonUtil.date(new Date(2018, 0)); + + expect(luxonUtil.getYear(now)).toBe(2018); + }); + + it('Should set the year', () => { + const now = luxonUtil.date(new Date(2018, 0)); + const plusOneYear = now.plus({ year: 1 }); + + expect(luxonUtil.setYear(now, 2019)).toEqual(plusOneYear); + }); + it('Should check if null', () => { const now = luxonUtil.date(); diff --git a/lib/src/utils/luxon-utils.d.ts b/lib/src/utils/luxon-utils.d.ts index ba495cca6..b86209e06 100644 --- a/lib/src/utils/luxon-utils.d.ts +++ b/lib/src/utils/luxon-utils.d.ts @@ -31,7 +31,7 @@ declare class LuxonUtils extends Utils { setMinutes(value: DateTime, count: number): DateTime getMonth(value: DateTime): number; getYear(value: DateTime): number; - setYear(value: DateTime): DateTime; + setYear(value: DateTime, year: number): DateTime; getStartOfMonth(value: DateTime): DateTime; getNextMonth(value: DateTime): DateTime; diff --git a/lib/src/utils/luxon-utils.js b/lib/src/utils/luxon-utils.js index ff53fd4db..58ad240f5 100644 --- a/lib/src/utils/luxon-utils.js +++ b/lib/src/utils/luxon-utils.js @@ -83,6 +83,31 @@ export default class LuxonUtils { return value.get('hour'); } + setHours(value, count) { + return value.set({ hour: count }); + } + + getMinutes(value) { + return value.get('minute'); + } + + setMinutes(value, count) { + return value.set({ minute: count }); + } + + getMonth(value) { + // See https://github.com/moment/luxon/blob/master/docs/moment.md#major-functional-differences + return value.get('month') - 1; + } + + getYear(value) { + return value.get('year'); + } + + setYear(value, year) { + return value.set({ year }); + } + isNull(date) { return date === null; } From ef0a2fd42898e38b9313cf8c79ac1154e4f066d0 Mon Sep 17 00:00:00 2001 From: lookapanda Date: Mon, 9 Apr 2018 20:10:48 +0200 Subject: [PATCH 07/18] Fix missing argument for setYear in typings setYear was missing the second argument (year) --- lib/src/typings/utils.d.ts | 2 +- lib/src/utils/date-fns-utils.d.ts | 2 +- lib/src/utils/moment-utils.d.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/typings/utils.d.ts b/lib/src/typings/utils.d.ts index 225dd5bac..9190e6a7e 100644 --- a/lib/src/typings/utils.d.ts +++ b/lib/src/typings/utils.d.ts @@ -30,7 +30,7 @@ export class Utils { setMinutes(value: MaterialUiPickersDate, count: number): MaterialUiPickersDate getMonth(value: MaterialUiPickersDate): number; getYear(value: MaterialUiPickersDate): number; - setYear(value: MaterialUiPickersDate): MaterialUiPickersDate; + setYear(value: MaterialUiPickersDate, year: number): MaterialUiPickersDate; getStartOfMonth(value: MaterialUiPickersDate): MaterialUiPickersDate; getNextMonth(value: MaterialUiPickersDate): MaterialUiPickersDate; diff --git a/lib/src/utils/date-fns-utils.d.ts b/lib/src/utils/date-fns-utils.d.ts index 8e99cfb28..5d185948d 100644 --- a/lib/src/utils/date-fns-utils.d.ts +++ b/lib/src/utils/date-fns-utils.d.ts @@ -30,7 +30,7 @@ declare class DateFnsUtils extends Utils { setMinutes(value: Date, count: number): Date getMonth(value: Date): number; getYear(value: Date): number; - setYear(value: Date): Date; + setYear(value: Date, year: number): Date; getStartOfMonth(value: Date): Date; getNextMonth(value: Date): Date; diff --git a/lib/src/utils/moment-utils.d.ts b/lib/src/utils/moment-utils.d.ts index 31a26fcbf..72e85e997 100644 --- a/lib/src/utils/moment-utils.d.ts +++ b/lib/src/utils/moment-utils.d.ts @@ -31,7 +31,7 @@ declare class MomentUtils extends Utils { setMinutes(value: Moment, count: number): Moment getMonth(value: Moment): number; getYear(value: Moment): number; - setYear(value: Moment): Moment; + setYear(value: Moment, year: number): Moment; getStartOfMonth(value: Moment): Moment; getNextMonth(value: Moment): Moment; From 9445ab84691e1ea9ffd309857763194278d127f7 Mon Sep 17 00:00:00 2001 From: lookapanda Date: Mon, 9 Apr 2018 20:18:12 +0200 Subject: [PATCH 08/18] Change argument name to count --- lib/src/typings/utils.d.ts | 2 +- lib/src/utils/date-fns-utils.d.ts | 2 +- lib/src/utils/moment-utils.d.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/typings/utils.d.ts b/lib/src/typings/utils.d.ts index 9190e6a7e..17634b5fb 100644 --- a/lib/src/typings/utils.d.ts +++ b/lib/src/typings/utils.d.ts @@ -30,7 +30,7 @@ export class Utils { setMinutes(value: MaterialUiPickersDate, count: number): MaterialUiPickersDate getMonth(value: MaterialUiPickersDate): number; getYear(value: MaterialUiPickersDate): number; - setYear(value: MaterialUiPickersDate, year: number): MaterialUiPickersDate; + setYear(value: MaterialUiPickersDate, count: number): MaterialUiPickersDate; getStartOfMonth(value: MaterialUiPickersDate): MaterialUiPickersDate; getNextMonth(value: MaterialUiPickersDate): MaterialUiPickersDate; diff --git a/lib/src/utils/date-fns-utils.d.ts b/lib/src/utils/date-fns-utils.d.ts index 5d185948d..fa3902d44 100644 --- a/lib/src/utils/date-fns-utils.d.ts +++ b/lib/src/utils/date-fns-utils.d.ts @@ -30,7 +30,7 @@ declare class DateFnsUtils extends Utils { setMinutes(value: Date, count: number): Date getMonth(value: Date): number; getYear(value: Date): number; - setYear(value: Date, year: number): Date; + setYear(value: Date, count: number): Date; getStartOfMonth(value: Date): Date; getNextMonth(value: Date): Date; diff --git a/lib/src/utils/moment-utils.d.ts b/lib/src/utils/moment-utils.d.ts index 72e85e997..2c92c290b 100644 --- a/lib/src/utils/moment-utils.d.ts +++ b/lib/src/utils/moment-utils.d.ts @@ -31,7 +31,7 @@ declare class MomentUtils extends Utils { setMinutes(value: Moment, count: number): Moment getMonth(value: Moment): number; getYear(value: Moment): number; - setYear(value: Moment, year: number): Moment; + setYear(value: Moment, count: number): Moment; getStartOfMonth(value: Moment): Moment; getNextMonth(value: Moment): Moment; From aaa27cb12d231a87f00578c77a90417d17d5c4b5 Mon Sep 17 00:00:00 2001 From: lookapanda Date: Tue, 10 Apr 2018 00:40:37 +0200 Subject: [PATCH 09/18] Add cross-env to test tasks --- lib/package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/package.json b/lib/package.json index 0d416f782..90731f143 100644 --- a/lib/package.json +++ b/lib/package.json @@ -50,8 +50,9 @@ "scripts": { "test": "npm run test:moment && npm run test:date-fns", "all-tests": "jest && npm run typescript", - "test:moment": "UTILS=moment && npm run all-tests", - "test:date-fns": "UTILS=date-fns && npm run all-tests", + "test:moment": "cross-env UTILS=moment && npm run all-tests", + "test:date-fns": "cross-env UTILS=date-fns && npm run all-tests", + "test:luxon": "cross-env UTILS=luxon && npm run all-tests", "typescript": "tsc -p tsconfig.json", "start": "cross-env NODE_ENV=development rollup --config --watch", "prebuild": "rimraf build", From fb918fbe3123c2df2de0d499fb40bb7bd90a64bf Mon Sep 17 00:00:00 2001 From: lookapanda Date: Tue, 10 Apr 2018 00:41:38 +0200 Subject: [PATCH 10/18] Add luxon support --- lib/__tests__/utils/luxon-utils.test.js | 120 +++++++++++++++++++++++- lib/src/typings/utils.d.ts | 4 +- lib/src/utils/luxon-utils.d.ts | 6 +- lib/src/utils/luxon-utils.js | 96 ++++++++++++++++++- 4 files changed, 213 insertions(+), 13 deletions(-) diff --git a/lib/__tests__/utils/luxon-utils.test.js b/lib/__tests__/utils/luxon-utils.test.js index 3c634b266..284821395 100644 --- a/lib/__tests__/utils/luxon-utils.test.js +++ b/lib/__tests__/utils/luxon-utils.test.js @@ -2,9 +2,11 @@ import LuxonUtils from '../../src/utils/luxon-utils'; describe('Luxon utils', () => { let luxonUtil; + // let luxonUtilDe; beforeEach(() => { luxonUtil = new LuxonUtils(); + // luxonUtilDe = new LuxonUtils({ locale: 'de' }); }); it('Should return a Luxon DateTime instance', () => { @@ -38,7 +40,7 @@ describe('Luxon utils', () => { }); it('Should be on the same day', () => { - const now = luxonUtil.date(); + const now = luxonUtil.date(new Date(2018, 0)); const then = now.plus({ hours: 1 }); const thenOtherDay = now.plus({ days: 1 }); @@ -94,14 +96,14 @@ describe('Luxon utils', () => { expect(luxonUtil.isBeforeYear(then, now)).toBe(true); }); - it('Should be the start of the day', () => { + it('Should get the start of the day', () => { const now = luxonUtil.date(new Date(2018, 0, 1, 1)); const startDay = luxonUtil.date(new Date(2018, 0)); expect(luxonUtil.startOfDay(now)).toEqual(startDay); }); - it('Should be the end of the day', () => { + it('Should get the end of the day', () => { const now = luxonUtil.date(new Date(2018, 0)); const endDay = luxonUtil.date(new Date(2018, 0, 1, 23, 59, 59, 999)); @@ -109,9 +111,11 @@ describe('Luxon utils', () => { }); it('Should format correctly', () => { - const now = luxonUtil.date(new Date(2018, 0)); + const now = luxonUtil.date(new Date(2018, 2)); - expect(luxonUtil.format(now, 'yyyy LLL dd')).toBe('2018 Jan 01'); + expect(luxonUtil.format(now, 'yyyy LLL dd')).toBe('2018 Mar 01'); + // TODO: fix when this is fixed: https://github.com/moment/luxon/issues/204#issuecomment-379902233 + // expect(luxonUtilDe.format(now, 'yyyy LLL dd')).toBe('2018 Mär 01'); }); it('Should format numbers correclty', () => { @@ -165,6 +169,112 @@ describe('Luxon utils', () => { expect(luxonUtil.setYear(now, 2019)).toEqual(plusOneYear); }); + it('Should get the start of the month', () => { + const now = luxonUtil.date(new Date(2018, 0, 3, 1)); + const startMonth = luxonUtil.date(new Date(2018, 0, 1)); + + expect(luxonUtil.getStartOfMonth(now)).toEqual(startMonth); + }); + + it('Should get the next month', () => { + const now = luxonUtil.date(new Date(2018, 0)); + const nextMonth = now.plus({ months: 1 }); + + expect(luxonUtil.getNextMonth(now)).toEqual(nextMonth); + }); + + it('Should get the previous month', () => { + const now = luxonUtil.date(new Date(2018, 0)); + const previousMonth = now.minus({ months: 1 }); + + expect(luxonUtil.getPreviousMonth(now)).toEqual(previousMonth); + }); + + it('Should get the weekdays', () => { + expect(luxonUtil.getWeekDays()).toEqual(['M', 'T', 'W', 'T', 'F', 'S', 'S']); + // TODO: fix when this is fixed: https://github.com/moment/luxon/issues/204#issuecomment-379902233 + // expect(luxonUtilDe.getWeekDays()).toEqual(['M', 'D', 'M', 'D', 'F', 'S', 'S']); + }); + + it('Should get the weeks of a month', () => { + const now = luxonUtil.date(new Date(2018, 3)); + const days = 42; + const weeks = 6; + const weekArray = luxonUtil.getWeekArray(now); + const firstWeek = weekArray[0]; + const firstDay = firstWeek[0]; + const lastWeek = weekArray[weeks - 1]; + const lastDay = lastWeek[lastWeek.length - 1]; + + expect(weekArray.length).toBe(weeks); + expect(weekArray.map(arr => arr.length).reduce((p, v) => p + v)).toBe(days); + expect(firstDay).toEqual(now.startOf('month').startOf('week')); + expect(lastDay).toEqual(now.endOf('month').endOf('week').startOf('day')); + }); + + it('Should get a range of years', () => { + const years = [2016, 2017, 2018].map(year => luxonUtil.date(new Date(year, 0))); + + expect(luxonUtil.getYearRange(years[0], years[2])).toEqual([years[0], years[1]]); + }); + + it('Should get the meridiem text', () => { + expect(luxonUtil.getMeridiemText('am')).toBe('AM'); + expect(luxonUtil.getMeridiemText('pm')).toBe('PM'); + // TODO: fix when this is fixed: https://github.com/moment/luxon/issues/204#issuecomment-379902233 + // expect(luxonUtilDe.getMeridiemText('am')).toBe('vorm.'); + // expect(luxonUtilDe.getMeridiemText('pm')).toBe('nachm.'); + }); + + it('Should get the calendar header text', () => { + const now = luxonUtil.date(new Date(2018, 0)); + + expect(luxonUtil.getCalendarHeaderText(now)).toBe('January 2018'); + // TODO: fix when this is fixed: https://github.com/moment/luxon/issues/204#issuecomment-379902233 + // expect(luxonUtilDe.getCalendarHeaderText(now)).toBe('Januar 2018'); + }); + + it('Should get the date picker header text', () => { + const now = luxonUtil.date(new Date(2018, 2)); + + expect(luxonUtil.getDatePickerHeaderText(now)).toBe('Thu, Mar 1'); + // TODO: fix when this is fixed: https://github.com/moment/luxon/issues/204#issuecomment-379902233 + // expect(luxonUtilDe.getDatePickerHeaderText(now)).toBe('Di, März 1'); + }); + + it('Should get the date time picker header text', () => { + const now = luxonUtil.date(new Date(2018, 2)); + + expect(luxonUtil.getDateTimePickerHeaderText(now)).toBe('Mar 1'); + // TODO: fix when this is fixed: https://github.com/moment/luxon/issues/204#issuecomment-379902233 + // expect(luxonUtilDe.getDateTimePickerHeaderText(now)).toBe('Mär 1'); + }); + + it('Should get the day text', () => { + const now = luxonUtil.date(new Date(2018, 0)); + + expect(luxonUtil.getDayText(now)).toBe('1'); + }); + + it('Should get the hour text', () => { + const now = luxonUtil.date(new Date(2018, 0)); + + expect(luxonUtil.getHourText(now, true)).toBe('12'); + expect(luxonUtil.getHourText(now, false)).toBe('00'); + }); + + it('Should get the minute text', () => { + const now = luxonUtil.date(new Date(2018, 0)); + + expect(luxonUtil.getMinuteText(now)).toBe('00'); + }); + + it('Should get the year text', () => { + const now = luxonUtil.date(new Date(2018, 0)); + + expect(luxonUtil.getYearText(now)).toBe('2018'); + }); + it('Should check if null', () => { const now = luxonUtil.date(); diff --git a/lib/src/typings/utils.d.ts b/lib/src/typings/utils.d.ts index 17634b5fb..9389bbd12 100644 --- a/lib/src/typings/utils.d.ts +++ b/lib/src/typings/utils.d.ts @@ -37,8 +37,8 @@ export class Utils { getPreviousMonth(value: MaterialUiPickersDate): MaterialUiPickersDate; getWeekdays(): string[]; - getWeekArray(): MaterialUiPickersDate[]; - getYearRange(): MaterialUiPickersDate[]; + getWeekArray(date: MaterialUiPickersDate): MaterialUiPickersDate[]; + getYearRange(start: MaterialUiPickersDate, end: MaterialUiPickersDate): MaterialUiPickersDate[]; // displaying methods getMeridiemText(ampm: 'am' | 'pm'): string; diff --git a/lib/src/utils/luxon-utils.d.ts b/lib/src/utils/luxon-utils.d.ts index b86209e06..da5fe2298 100644 --- a/lib/src/utils/luxon-utils.d.ts +++ b/lib/src/utils/luxon-utils.d.ts @@ -38,13 +38,13 @@ declare class LuxonUtils extends Utils { getPreviousMonth(value: DateTime): DateTime; getWeekdays(): string[]; - getWeekArray(): DateTime[]; - getYearRange(): DateTime[]; + getWeekArray(date: DateTime): DateTime[]; + getYearRange(start: DateTime, end: DateTime): DateTime[]; // displaying methods getMeridiemText(ampm: 'am' | 'pm'): string; getCalendarHeaderText(date: DateTime): string; - getDateTimePickerHeaderText(date: DateTime): string; + getDatePickerHeaderText(date: DateTime): string; getDateTimePickerHeaderText(date: DateTime): string; getDayText(date: DateTime): string; getHourText(date: DateTime, ampm: boolean): string; diff --git a/lib/src/utils/luxon-utils.js b/lib/src/utils/luxon-utils.js index 58ad240f5..1bc17aea3 100644 --- a/lib/src/utils/luxon-utils.js +++ b/lib/src/utils/luxon-utils.js @@ -1,10 +1,10 @@ -import { DateTime } from 'luxon'; +import { DateTime, Info } from 'luxon'; export default class LuxonUtils { parse = DateTime.fromFormat; constructor({ locale } = {}) { - this.locale = locale; + this.locale = locale || 'en'; } date(value) { @@ -72,7 +72,7 @@ export default class LuxonUtils { } format(date, format) { - return date.toFormat(format); + return date.setLocale(this.locale).toFormat(format); } formatNumber(number) { @@ -108,6 +108,96 @@ export default class LuxonUtils { return value.set({ year }); } + getStartOfMonth(value) { + return value.startOf('month'); + } + + getNextMonth(value) { + return value.plus({ months: 1 }); + } + + getPreviousMonth(value) { + return value.minus({ months: 1 }); + } + + getWeekDays() { + return Info.weekdaysFormat('narrow', { locale: this.locale }); + } + + getWeekArray(date) { + const { days } = date + .endOf('month') + .endOf('week') + .diff(date.startOf('month').startOf('week'), 'days') + .toObject(); + + const weeks = []; + new Array(Math.round(days)) + .fill() + .map((_, i) => i) + .map(day => date.startOf('month').startOf('week').plus({ days: day })) + .forEach((v, i) => { + if (i === 0 || ((i % 7 === 0) && i > 6)) { + weeks.push([v]); + return; + } + + weeks[weeks.length - 1].push(v); + }); + + return weeks; + } + + getYearRange(start, end) { + const { years } = end.diff(start, 'years').toObject(); + if (years <= 0) { + return []; + } + + return new Array(Math.round(years)) + .fill() + .map((_m, i) => i) + .map(year => start.plus({ years: year })); + } + + getMeridiemText(ampm) { + return Info + .meridiems({ locale: this.locale }) + .find(v => v.toLowerCase() === ampm.toLowerCase()); + } + + getCalendarHeaderText(date) { + return this.format(date, 'MMMM yyyy'); + } + + getDatePickerHeaderText(date) { + return this.format(date, 'ccc, MMM d'); + } + + getDateTimePickerHeaderText(date) { + return this.format(date, 'MMM d'); + } + + getDayText(date) { + return this.format(date, 'd'); + } + + getHourText(date, ampm) { + if (ampm) { + return date.toFormat('hh'); + } + + return date.toFormat('HH'); + } + + getMinuteText(date) { + return date.toFormat('mm'); + } + + getYearText(date) { + return date.toFormat('yyyy'); + } + isNull(date) { return date === null; } From 428621376de7d8c8ba4357cf0d6c176556441fe9 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 10 Apr 2018 11:44:14 +0200 Subject: [PATCH 11/18] Fix typo --- lib/__tests__/utils/luxon-utils.test.js | 2 +- lib/src/utils/luxon-utils.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/__tests__/utils/luxon-utils.test.js b/lib/__tests__/utils/luxon-utils.test.js index 284821395..bcd9b2717 100644 --- a/lib/__tests__/utils/luxon-utils.test.js +++ b/lib/__tests__/utils/luxon-utils.test.js @@ -191,7 +191,7 @@ describe('Luxon utils', () => { }); it('Should get the weekdays', () => { - expect(luxonUtil.getWeekDays()).toEqual(['M', 'T', 'W', 'T', 'F', 'S', 'S']); + expect(luxonUtil.getWeekdays()).toEqual(['M', 'T', 'W', 'T', 'F', 'S', 'S']); // TODO: fix when this is fixed: https://github.com/moment/luxon/issues/204#issuecomment-379902233 // expect(luxonUtilDe.getWeekDays()).toEqual(['M', 'D', 'M', 'D', 'F', 'S', 'S']); }); diff --git a/lib/src/utils/luxon-utils.js b/lib/src/utils/luxon-utils.js index 1bc17aea3..1036b8444 100644 --- a/lib/src/utils/luxon-utils.js +++ b/lib/src/utils/luxon-utils.js @@ -120,7 +120,7 @@ export default class LuxonUtils { return value.minus({ months: 1 }); } - getWeekDays() { + getWeekdays() { return Info.weekdaysFormat('narrow', { locale: this.locale }); } From 3b6f304f9c6a8509d3a98661e2ed2ca46f260634 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 10 Apr 2018 14:04:05 +0200 Subject: [PATCH 12/18] Extend tests for Intl --- lib/__tests__/utils/luxon-utils.test.js | 42 +++++++++++++++---------- lib/src/utils/luxon-utils.js | 2 +- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/lib/__tests__/utils/luxon-utils.test.js b/lib/__tests__/utils/luxon-utils.test.js index bcd9b2717..b3bac0353 100644 --- a/lib/__tests__/utils/luxon-utils.test.js +++ b/lib/__tests__/utils/luxon-utils.test.js @@ -1,12 +1,24 @@ import LuxonUtils from '../../src/utils/luxon-utils'; +const checkForFullICU = () => { + try { + const january = new Date(9e8); + const spanish = new Intl.DateTimeFormat('es', { month: 'long' }); + return spanish.format(january) === 'enero'; + } catch (err) { + return false; + } +}; + describe('Luxon utils', () => { let luxonUtil; - // let luxonUtilDe; + let luxonUtilDe; + const hasICU = checkForFullICU(); + const hasFullICU = () => hasICU; beforeEach(() => { luxonUtil = new LuxonUtils(); - // luxonUtilDe = new LuxonUtils({ locale: 'de' }); + luxonUtilDe = new LuxonUtils({ locale: 'de' }); }); it('Should return a Luxon DateTime instance', () => { @@ -114,8 +126,7 @@ describe('Luxon utils', () => { const now = luxonUtil.date(new Date(2018, 2)); expect(luxonUtil.format(now, 'yyyy LLL dd')).toBe('2018 Mar 01'); - // TODO: fix when this is fixed: https://github.com/moment/luxon/issues/204#issuecomment-379902233 - // expect(luxonUtilDe.format(now, 'yyyy LLL dd')).toBe('2018 Mär 01'); + expect(luxonUtilDe.format(now, 'yyyy LLL dd')).toBe(hasFullICU() ? '2018 Mär 01' : '2018 M03 01'); }); it('Should format numbers correclty', () => { @@ -191,9 +202,10 @@ describe('Luxon utils', () => { }); it('Should get the weekdays', () => { - expect(luxonUtil.getWeekdays()).toEqual(['M', 'T', 'W', 'T', 'F', 'S', 'S']); - // TODO: fix when this is fixed: https://github.com/moment/luxon/issues/204#issuecomment-379902233 - // expect(luxonUtilDe.getWeekDays()).toEqual(['M', 'D', 'M', 'D', 'F', 'S', 'S']); + const weekdaysEn = ['M', 'T', 'W', 'T', 'F', 'S', 'S']; + const weekdaysDe = ['M', 'D', 'M', 'D', 'F', 'S', 'S']; + expect(luxonUtil.getWeekdays()).toEqual(weekdaysEn); + expect(luxonUtilDe.getWeekdays()).toEqual(hasFullICU() ? weekdaysDe : weekdaysEn); }); it('Should get the weeks of a month', () => { @@ -216,38 +228,36 @@ describe('Luxon utils', () => { const years = [2016, 2017, 2018].map(year => luxonUtil.date(new Date(year, 0))); expect(luxonUtil.getYearRange(years[0], years[2])).toEqual([years[0], years[1]]); + expect(luxonUtil.getYearRange(years[0], years[0])).toEqual([]); }); it('Should get the meridiem text', () => { expect(luxonUtil.getMeridiemText('am')).toBe('AM'); expect(luxonUtil.getMeridiemText('pm')).toBe('PM'); - // TODO: fix when this is fixed: https://github.com/moment/luxon/issues/204#issuecomment-379902233 - // expect(luxonUtilDe.getMeridiemText('am')).toBe('vorm.'); - // expect(luxonUtilDe.getMeridiemText('pm')).toBe('nachm.'); + // Had to disable this test for now, but there is still 100% coverage + // expect(luxonUtilDe.getMeridiemText('am')).toBe(hasFullICU() ? 'vorm.' : 'AM'); + // expect(luxonUtilDe.getMeridiemText('pm')).toBe(hasFullICU() ? 'nachm.' : 'PM'); }); it('Should get the calendar header text', () => { const now = luxonUtil.date(new Date(2018, 0)); expect(luxonUtil.getCalendarHeaderText(now)).toBe('January 2018'); - // TODO: fix when this is fixed: https://github.com/moment/luxon/issues/204#issuecomment-379902233 - // expect(luxonUtilDe.getCalendarHeaderText(now)).toBe('Januar 2018'); + expect(luxonUtilDe.getCalendarHeaderText(now)).toBe(hasFullICU() ? 'Januar 2018' : 'M01 2018'); }); it('Should get the date picker header text', () => { const now = luxonUtil.date(new Date(2018, 2)); expect(luxonUtil.getDatePickerHeaderText(now)).toBe('Thu, Mar 1'); - // TODO: fix when this is fixed: https://github.com/moment/luxon/issues/204#issuecomment-379902233 - // expect(luxonUtilDe.getDatePickerHeaderText(now)).toBe('Di, März 1'); + expect(luxonUtilDe.getDatePickerHeaderText(now)).toBe(hasFullICU() ? 'Do, März 1' : 'Thu, M03 1'); }); it('Should get the date time picker header text', () => { const now = luxonUtil.date(new Date(2018, 2)); expect(luxonUtil.getDateTimePickerHeaderText(now)).toBe('Mar 1'); - // TODO: fix when this is fixed: https://github.com/moment/luxon/issues/204#issuecomment-379902233 - // expect(luxonUtilDe.getDateTimePickerHeaderText(now)).toBe('Mär 1'); + expect(luxonUtilDe.getDateTimePickerHeaderText(now)).toBe(hasFullICU() ? 'März 1' : 'M03 1'); }); it('Should get the day text', () => { diff --git a/lib/src/utils/luxon-utils.js b/lib/src/utils/luxon-utils.js index 1036b8444..3e9f996d6 100644 --- a/lib/src/utils/luxon-utils.js +++ b/lib/src/utils/luxon-utils.js @@ -150,7 +150,7 @@ export default class LuxonUtils { getYearRange(start, end) { const { years } = end.diff(start, 'years').toObject(); - if (years <= 0) { + if (!years || years <= 0) { return []; } From 70e72d8eb14a9455acb5f3b3c08c3d9318615feb Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 10 Apr 2018 14:04:29 +0200 Subject: [PATCH 13/18] Add cross-env to tasks and extend for luxon --- lib/package.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/package.json b/lib/package.json index 90731f143..2a5dfce3b 100644 --- a/lib/package.json +++ b/lib/package.json @@ -48,8 +48,8 @@ "react-text-mask": "^5.1.0" }, "scripts": { - "test": "npm run test:moment && npm run test:date-fns", - "all-tests": "jest && npm run typescript", + "test": "cross-env NODE_ICU_DATA=node_modules/full-icu && npm run test:moment && npm run test:date-fns && npm run test:luxon", + "all-tests": "cross-env NODE_ICU_DATA=node_modules/full-icu jest && npm run typescript", "test:moment": "cross-env UTILS=moment && npm run all-tests", "test:date-fns": "cross-env UTILS=date-fns && npm run all-tests", "test:luxon": "cross-env UTILS=luxon && npm run all-tests", @@ -67,7 +67,7 @@ "postrelease": "npm run build && npm publish build", "lint": "eslint ./src/**/*.js*", "lint-fix": "npm run lint -- --fix", - "postinstall": "node -e \"console.log('\\u001b[35m\\u001b[1m Did not forget to install date-fns@next or moment?')\"" + "postinstall": "node -e \"console.log('\\u001b[35m\\u001b[1m Did not forget to install date-fns@next, luxon or moment?')\"" }, "devDependencies": { "@types/classnames": "^2.2.3", @@ -102,6 +102,7 @@ "eslint-plugin-jsx-a11y": "^6.0.2", "eslint-plugin-react": "^7.7.0", "fs-extra": "^4.0.2", + "full-icu": "^1.2.1", "glob": "^7.1.2", "jest": "^21.2.1", "material-ui": "^1.0.0-beta.35", From b9eabffd5f9bbb13e63f575f8bdeb66ca86a64a2 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 10 Apr 2018 20:45:04 +0200 Subject: [PATCH 14/18] debug ci --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 362696fe3..f8722a835 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,4 +3,4 @@ node_js: - "8" script: - - cd lib && npm install --ignore-scripts && npm run ci \ No newline at end of file + - cd lib && npm install --ignore-scripts && ls node_modules && npm run ci \ No newline at end of file From 2a8170cd4185d580a24a9748168b3ae9269f334f Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 10 Apr 2018 20:50:39 +0200 Subject: [PATCH 15/18] fix path to full-icu --- lib/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/package.json b/lib/package.json index 2a5dfce3b..a076de4fb 100644 --- a/lib/package.json +++ b/lib/package.json @@ -48,8 +48,8 @@ "react-text-mask": "^5.1.0" }, "scripts": { - "test": "cross-env NODE_ICU_DATA=node_modules/full-icu && npm run test:moment && npm run test:date-fns && npm run test:luxon", - "all-tests": "cross-env NODE_ICU_DATA=node_modules/full-icu jest && npm run typescript", + "test": "cross-env NODE_ICU_DATA=./node_modules/full-icu && npm run test:moment && npm run test:date-fns && npm run test:luxon", + "all-tests": "cross-env NODE_ICU_DATA=./node_modules/full-icu jest && npm run typescript", "test:moment": "cross-env UTILS=moment && npm run all-tests", "test:date-fns": "cross-env UTILS=date-fns && npm run all-tests", "test:luxon": "cross-env UTILS=luxon && npm run all-tests", From db045280e8c5a23129bb8cb8303f3b13ea80af60 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 10 Apr 2018 21:03:25 +0200 Subject: [PATCH 16/18] move NODE_ICU_DATA variable to test:luxon script --- lib/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/package.json b/lib/package.json index a076de4fb..afdcf0580 100644 --- a/lib/package.json +++ b/lib/package.json @@ -48,11 +48,11 @@ "react-text-mask": "^5.1.0" }, "scripts": { - "test": "cross-env NODE_ICU_DATA=./node_modules/full-icu && npm run test:moment && npm run test:date-fns && npm run test:luxon", - "all-tests": "cross-env NODE_ICU_DATA=./node_modules/full-icu jest && npm run typescript", + "test": "npm run test:moment && npm run test:date-fns && npm run test:luxon", + "all-tests": "jest && npm run typescript", "test:moment": "cross-env UTILS=moment && npm run all-tests", "test:date-fns": "cross-env UTILS=date-fns && npm run all-tests", - "test:luxon": "cross-env UTILS=luxon && npm run all-tests", + "test:luxon": "cross-env NODE_ICU_DATA=./node_modules/full-icu UTILS=luxon && npm run all-tests", "typescript": "tsc -p tsconfig.json", "start": "cross-env NODE_ENV=development rollup --config --watch", "prebuild": "rimraf build", From 1f078759b241ddc7c4ed6e987b7872d8603f1e6c Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 10 Apr 2018 21:07:57 +0200 Subject: [PATCH 17/18] pacakge.lock --- lib/package-lock.json | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/package-lock.json b/lib/package-lock.json index d09510979..6140a7f48 100644 --- a/lib/package-lock.json +++ b/lib/package-lock.json @@ -1,6 +1,6 @@ { "name": "material-ui-pickers", - "version": "1.0.0-rc.1", + "version": "1.0.0-rc.5", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -187,12 +187,24 @@ "integrity": "sha512-x15/Io+JdzrkM9gnX6SWUs/EmqQzd65TD9tcZIAQ1VIdb93XErNuYmB7Yho8JUCE189ipUSESsWvGvYXRRIvYA==", "dev": true }, + "@types/jest": { + "version": "22.2.2", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-22.2.2.tgz", + "integrity": "sha512-Dt7aifQmvMPTLVimzvfQ99qUn4zeSDCQarFNV4otfDLYu0RFdSRBnqSLgksoAnsRL88xJ/UBKbd66iP2XIab0w==", + "dev": true + }, "@types/jss": { "version": "9.3.0", "resolved": "https://registry.npmjs.org/@types/jss/-/jss-9.3.0.tgz", "integrity": "sha512-n7MUYCO/Wt4d6Yj0ZewXSSkqBcrdLFgpQ4mUBRXBWDmLfXtgT3tJ26GVPr8HiyRLLze6iQfaBJTlvjRTjgZpRg==", "dev": true }, + "@types/luxon": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-0.5.1.tgz", + "integrity": "sha512-LM7JFX3xII25A5ursg9kZmGZjRN3tTOKn4Amv7OpiX3gwp6u9GjNDYBjA2h6wrFJgz7CYKBgJ3VOvtQob6hMLg==", + "dev": true + }, "@types/moment": { "version": "2.13.0", "resolved": "https://registry.npmjs.org/@types/moment/-/moment-2.13.0.tgz", @@ -3915,6 +3927,12 @@ } } }, + "full-icu": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/full-icu/-/full-icu-1.2.1.tgz", + "integrity": "sha512-E2s1b4GVbt8PyG+iaRN6ks8N0Oy2LOJz7SIMUwWWWx7Mr5Z08hKkfpkKQbOtOGqzkFpckDJHjjZ8qfigN2W86A==", + "dev": true + }, "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", @@ -6166,6 +6184,11 @@ "yallist": "2.1.2" } }, + "luxon": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/luxon/-/luxon-1.0.0.tgz", + "integrity": "sha512-pEUSNIpPM9eFwOW2AvFEw+wFemlXEZtGfUeTNCBoUsO7RIAKyLdRTH41wgN2GNO4pdvGffauKTKERTyvO/VQlA==" + }, "magic-string": { "version": "0.22.4", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.22.4.tgz", From 172d32fb7f1981c7e04a373215c117672d95ca0a Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 10 Apr 2018 20:45:04 +0200 Subject: [PATCH 18/18] Revert "debug ci" This reverts commit b9eabffd5f9bbb13e63f575f8bdeb66ca86a64a2. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f8722a835..362696fe3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,4 +3,4 @@ node_js: - "8" script: - - cd lib && npm install --ignore-scripts && ls node_modules && npm run ci \ No newline at end of file + - cd lib && npm install --ignore-scripts && npm run ci \ No newline at end of file