10 examples of 'react native moment' in JavaScript

Every line of 'react native moment' 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
this disclaimer
206newMoment(...args) {
207 let m = null
208
209 if (args.length < 1) {
210 // if no args, use the current date/time (cannot pass in null otherwise time is zeroed)
211 m = moment()
212 }
213 else {
214 m = moment(...args)
215 }
216
217 m.utc()
218 m.locale(this.config.lang)
219 return m
220}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

1532componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
1533 var value = nextProps.value;
1534 var selectedValue = nextProps.selectedValue;
1535
1536 if ('value' in nextProps) {
1537 value = value || nextProps.defaultValue || getNowByCurrentStateValue(this.state.value);
1538 this.setState({
1539 value: value
1540 });
1541 }
1542 if ('selectedValue' in nextProps) {
1543 this.setState({
1544 selectedValue: selectedValue
1545 });
1546 }
1547},
30export function useMoment() {
31 const { i18n } = useTranslations();
32 const { currentUser } = useCurrentUser();
33 const { timezone } = attributesFor(currentUser);
34
35 moment.locale(i18n.language);
36
37 return {
38 moment,
39 timezone: timezone || moment.tz.guess(),
40 };
41}
6constructor(props) {
7 super(props);
8 this.state = {
9 value: momentJalaali('1396/7/6', 'jYYYY/jM/jD')
10 };
11}
41componentWillReceiveProps(props) {
42 const attrs = transformAttrs(props);
43 this.setState({
44 attributes: attrs,
45 transformedAttrs: attrs
46 });
47}
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}
139get _hasNative() {
140 return DatetimePicker._hasNative;
141}
22getMoment() {
23 let mom = this.props.moment ? this.props.moment.clone() : moment();
24
25 if (this.props.locale) {
26 mom = mom.locale(this.props.locale);
27 }
28
29 return mom;
30}
174value: function componentWillMount() {
175 this.setState({
176 displayDate: this.props.utils.getFirstDayOfMonth(this.props.initialDate),
177 selectedDate: this.props.initialDate,
178 displayMonthDay: !this.props.openToYearSelection
179 });
180}
22patchReactNativeWithZone(zone: any): void {}

Related snippets