Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ public class RNDate {

public RNDate(Bundle args) {
now = Calendar.getInstance();
if (args != null && args.containsKey(RNConstants.ARG_TZOFFSET_MINS)) {
now.setTimeZone(TimeZone.getTimeZone("GMT"));
Integer timeZoneOffsetInMinutes = args.getInt(RNConstants.ARG_TZOFFSET_MINS);
now.add(Calendar.MILLISECOND, timeZoneOffsetInMinutes * 60000);
}

if (args != null && args.containsKey(RNConstants.ARG_VALUE)) {
set(args.getLong(RNConstants.ARG_VALUE));
}

if (args != null && args.containsKey(RNConstants.ARG_TZOFFSET_MINS)) {
now.setTimeZone(TimeZone.getTimeZone("GMT"));
Long timeZoneOffsetInMinutesFallback = args.getLong(RNConstants.ARG_TZOFFSET_MINS);
Integer timeZoneOffsetInMinutes = args.getInt(RNConstants.ARG_TZOFFSET_MINS, timeZoneOffsetInMinutesFallback.intValue());
now.add(Calendar.MILLISECOND, timeZoneOffsetInMinutes * 60000);
}
}

public void set(long value) {
Expand Down
11 changes: 4 additions & 7 deletions example/e2e/detoxTest.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,14 @@ describe('Example', () => {

if (isIOS()) {
const testElement = getDateTimePickerIOS();
await testElement.setColumnToValue(0, '2');
await testElement.setColumnToValue(1, '44');
await testElement.setColumnToValue(2, 'PM');

await expect(timeText).toHaveText('13:44');
await testElement.setColumnToValue(0, '12');
await testElement.setColumnToValue(1, '30');
await testElement.setColumnToValue(2, 'AM');
} else {
await userChangesMinuteValue();
await userTapsOkButtonAndroid();

await expect(timeText).toHaveText('22:30');
}
await expect(timeText).toHaveText('23:30');
});

it(':android: given we specify neutralButtonLabel, tapping the corresponding button sets date to the beginning of the unix time epoch', async () => {
Expand Down
5 changes: 1 addition & 4 deletions src/datetimepicker.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@ function getPicker({

function timeZoneOffsetDateSetter(date, timeZoneOffsetInMinutes) {
let localDate = date;
if (
typeof timeZoneOffsetInMinutes !== 'undefined' &&
timeZoneOffsetInMinutes >= 0
) {
if (typeof timeZoneOffsetInMinutes === 'number') {
const offset =
localDate.getTimezoneOffset() * MIN_MS + timeZoneOffsetInMinutes * MIN_MS;
localDate = new Date(date.getTime() - offset);
Expand Down