10 examples of 'react new date' in JavaScript

Every line of 'react new date' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
85var setDate = function setDate(start, end) {
86 var result = {
87 left: start,
88 right: end
89 }; // 当开始日期和结束日期在同一个月,根据不同的业务场景设置左右日历
90
91 if ((0, _date.equalYearAndMonth)(start, end)) {
92 if (props.scene === 'past') {
93 result = {
94 left: (0, _date.prevMonth)(end),
95 right: end
96 };
97 } else {
98 result = {
99 left: start,
100 right: (0, _date.nextMonth)(start)
101 };
102 }
103 }
104
105 return result;
106};
159static getDerivedStateFromProps(nextProps, prevState) {
160 const { selectedDate, value } = nextProps;
161 let nextDateValue = selectedDate;
162
163 // Use the value for a controlled component if one is provided.
164 if (value !== undefined && value !== null) {
165 nextDateValue = value;
166 }
167
168 if (nextDateValue !== prevState.prevPropsSelectedDate) {
169 const nextSelectedDate = DateUtil.createSafeDate(nextDateValue);
170
171 if (nextSelectedDate) {
172 return {
173 selectedDate: nextSelectedDate,
174 prevPropsSelectedDate: nextDateValue,
175 };
176 }
177
178 return {
179 prevPropsSelectedDate: nextDateValue,
180 };
181 }
182
183 return null;
184}
182getDateInstance( v ) {
183 return this.props.moment( v ).toDate();
184}
135set date(date) {
136 this._date = date;
137 /* only notify change when an actual date was set, when resetting time
138 * time and date (to use "Leave Now" routing) time would be set to null
139 * triggering an update */
140 if (date)
141 this.notify('points');
142}
162_cloneDate ( date ) {
163
164 return new Date ( date.getTime () );
165
166}
64handleChange(date) {
65 if (!date) {
66 if (this.props.onChange) {
67 this.props.onChange(null, null, '');
68 }
69 return;
70 }
71 if (this.props.onChange) {
72 this.props.onChange(
73 date.toDate().toISOString(), // ISO 8601
74 date.format(this.props.dateFormat), // 使用moment.js按照用户指定的格式进行格式化
75 date
76 );
77 }
78}
182value: function componentWillReceiveProps(nextProps) {
183 if (nextProps.initialDate !== this.props.initialDate) {
184 var date = nextProps.initialDate || new Date();
185 this.setState({
186 displayDate: this.props.utils.getFirstDayOfMonth(date),
187 selectedDate: date
188 });
189 }
190}
285getDate() {
286 return new Date(this.date.getTime());
287}
4componentDidMount(){
5 this.getDate()
6
7}
32function newDate(y, m, d) {
33 return {y: y, m: m, d: d, H: 0, M: 0, S: 0, L: 0};
34}

Related snippets