From 0bbafcda3a2632b91c07ceba25ad93e5d1872923 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 9 Aug 2018 11:33:39 -0700 Subject: [PATCH] react-select: Remove "moment" dependency (#27910) --- .../test/examples/Experimental.tsx | 23 +++++-------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/types/react-select/test/examples/Experimental.tsx b/types/react-select/test/examples/Experimental.tsx index 1317abbf5a..7491b37d35 100644 --- a/types/react-select/test/examples/Experimental.tsx +++ b/types/react-select/test/examples/Experimental.tsx @@ -1,22 +1,13 @@ import * as React from 'react'; -import * as moment from 'moment'; import * as chrono from '../ChronoNodeDummy'; import Select, { components as SelectComponents } from 'react-select'; -const createOptionForDate = (d: any) => { - const date = moment.isMoment(d) ? d : moment(d); +const createOptionForDate = (date: Date) => { return { date, - value: date.toDate(), - label: date.calendar(undefined, { - sameDay: '[Today] (Do MMM YYYY)', - nextDay: '[Tomorrow] (Do MMM YYYY)', - nextWeek: '[Next] dddd (Do MMM YYYY)', - lastDay: '[Yesterday] (Do MMM YYYY)', - lastWeek: '[Last] dddd (Do MMM YYYY)', - sameElse: 'Do MMMM YYYY', - }), + value: date, + label: "some label", }; }; @@ -25,15 +16,13 @@ const defaultOptions: any = ['today', 'tomorrow', 'yesterday'].map(i => ); const createCalendarOptions = (date = new Date()) => { - // $FlowFixMe const daysInMonth = Array.apply(null, { - length: moment(date).daysInMonth(), + length: date.getUTCDate(), }).map((x: any, i: number) => { - const d = moment(date).date(i + 1); - return { ...createOptionForDate(d), display: 'calendar' }; + return { ...createOptionForDate(date), display: 'calendar' }; }); return { - label: moment(date).format('MMMM YYYY'), + label: date.toDateString(), options: daysInMonth, }; };