diff --git a/android/src/main/java/com/henninghall/date_picker/wheels/AmPmWheel.java b/android/src/main/java/com/henninghall/date_picker/wheels/AmPmWheel.java index 233e416..cdad586 100644 --- a/android/src/main/java/com/henninghall/date_picker/wheels/AmPmWheel.java +++ b/android/src/main/java/com/henninghall/date_picker/wheels/AmPmWheel.java @@ -20,6 +20,9 @@ public class AmPmWheel extends Wheel { @Override public ArrayList getValues() { Calendar cal = Calendar.getInstance(); + // Getting the hours from a date that will never have daylight saving to be sure + // cal.add() will work properly. + cal.set(2000,0,0,0,0,0); ArrayList values = new ArrayList<>(); cal.set(Calendar.HOUR_OF_DAY, 0); diff --git a/android/src/main/java/com/henninghall/date_picker/wheels/HourWheel.java b/android/src/main/java/com/henninghall/date_picker/wheels/HourWheel.java index 4b51e1b..d7fd9b1 100644 --- a/android/src/main/java/com/henninghall/date_picker/wheels/HourWheel.java +++ b/android/src/main/java/com/henninghall/date_picker/wheels/HourWheel.java @@ -19,6 +19,10 @@ public class HourWheel extends Wheel { @Override public ArrayList getValues() { Calendar cal = Calendar.getInstance(); + // Getting the hours from a date that doesn't have daylight saving to be sure + // cal.add() will work properly. + cal.set(2000,0,0,0,0,0); + ArrayList values = new ArrayList<>(); int numberOfHours = state.derived.usesAmPm() ? 12 : 24; diff --git a/examples/manual-tests/daylight-saving.md b/examples/manual-tests/daylight-saving.md new file mode 100644 index 0000000..844b6fc --- /dev/null +++ b/examples/manual-tests/daylight-saving.md @@ -0,0 +1,19 @@ +# Daylight saving testing + +I haven't found an automatic way to change the time on the emulator to be able to run these tests automatically. + +## Test: AM/PM wheel should have proper values + +1. Set the timezone to GMT-07:00 Pacific Standard Time. +1. Set the time to 2020-11-01 +1. Set 24h setting to false. (AM/PM=true) +1. Go to time or datetime picker +1. Expect: Both AM and PM being in visible in AM/PM wheel. + +## Test: Hour wheel should have proper values + +1. Set the timezone to GMT-07:00 Pacific Standard Time. +1. Set the time to 2020-10-31 8:00 PM +1. Set 24h setting to false. (AM/PM=true) +1. Go to time or datetime picker. +1. Expect: All hours to exist on hour wheel and no hour missing.