Browse Source

fix: bugs occurring on daylight saving day (#291)

* fix: am/am being shown on daylight saving day

* fix: daylight saving hour wheel missing/extra hour
master
Henning Hall 4 years ago
committed by GitHub
parent
commit
b01915bdc8
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 0 deletions
  1. +3
    -0
      android/src/main/java/com/henninghall/date_picker/wheels/AmPmWheel.java
  2. +4
    -0
      android/src/main/java/com/henninghall/date_picker/wheels/HourWheel.java
  3. +19
    -0
      examples/manual-tests/daylight-saving.md

+ 3
- 0
android/src/main/java/com/henninghall/date_picker/wheels/AmPmWheel.java View File

@ -20,6 +20,9 @@ public class AmPmWheel extends Wheel {
@Override
public ArrayList<String> 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<String> values = new ArrayList<>();
cal.set(Calendar.HOUR_OF_DAY, 0);

+ 4
- 0
android/src/main/java/com/henninghall/date_picker/wheels/HourWheel.java View File

@ -19,6 +19,10 @@ public class HourWheel extends Wheel {
@Override
public ArrayList<String> 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<String> values = new ArrayList<>();
int numberOfHours = state.derived.usesAmPm() ? 12 : 24;

+ 19
- 0
examples/manual-tests/daylight-saving.md View File

@ -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.

Loading…
Cancel
Save