react-native-date-picker
Advanced tools
Comparing version 3.2.3 to 3.2.4
{ | ||
"name": "react-native-date-picker", | ||
"version": "3.2.3", | ||
"version": "3.2.4", | ||
"description": "A Cross Platform React Native Picker", | ||
@@ -32,3 +32,2 @@ "main": "src/index.js", | ||
"dependencies": { | ||
"moment": "^2.22.1" | ||
}, | ||
@@ -35,0 +34,0 @@ "devDependencies": { |
import React from 'react' | ||
import { StyleSheet, requireNativeComponent } from 'react-native' | ||
import moment from 'moment' | ||
function addMinutes(date, minutesToAdd) { | ||
return new Date(date.valueOf() + minutesToAdd * 60 * 1000) | ||
} | ||
const NativeDatePicker = requireNativeComponent( | ||
@@ -36,3 +39,3 @@ `DatePickerManager`, | ||
_onChange = e => { | ||
const jsDate = this._fromIsoWithTimeZoneOffset(e.nativeEvent.date).toDate() | ||
const jsDate = this._fromIsoWithTimeZoneOffset(e.nativeEvent.date) | ||
this.props.onDateChange && this.props.onDateChange(jsDate) | ||
@@ -54,8 +57,6 @@ if (this.props.onDateStringChange) { | ||
_fromIsoWithTimeZoneOffset = date => { | ||
if (this.props.timeZoneOffsetInMinutes === undefined) return moment(date) | ||
return moment | ||
.utc(date) | ||
.subtract(this.props.timeZoneOffsetInMinutes, 'minutes') | ||
_fromIsoWithTimeZoneOffset = timestamp => { | ||
const date = new Date(timestamp) | ||
if (this.props.timeZoneOffsetInMinutes === undefined) return date | ||
return addMinutes(date, -this.props.timeZoneOffsetInMinutes) | ||
} | ||
@@ -65,8 +66,5 @@ | ||
if (this.props.timeZoneOffsetInMinutes === undefined) | ||
return moment(date).toISOString() | ||
return date.toISOString() | ||
return moment | ||
.utc(date) | ||
.add(this.props.timeZoneOffsetInMinutes, 'minutes') | ||
.toISOString() | ||
return addMinutes(date, this.props.timeZoneOffsetInMinutes).toISOString() | ||
} | ||
@@ -73,0 +71,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
141831
0
498
- Removedmoment@^2.22.1
- Removedmoment@2.30.1(transitive)