Commit a650e04

derdilla <82763757+NobodyForNothing@users.noreply.github.com>
2024-04-06 06:22:40
fix daylight savings related bug
Signed-off-by: derdilla <82763757+NobodyForNothing@users.noreply.github.com>
1 parent 732a11a
Changed files (1)
app
lib
model
app/lib/model/storage/intervall_store.dart
@@ -70,25 +70,27 @@ class IntervallStorage extends ChangeNotifier {
     switch (stepSize) {
       case TimeStep.day:
         currentRange = DateTimeRange(
-          start: oldStart.copyWith(day: oldStart.day + directionalStep),
-          end: oldEnd.copyWith(day: oldEnd.day + directionalStep),
+          start: oldStart.add(Duration(days: directionalStep)),
+          end: oldEnd.add(Duration(days: directionalStep)),
         );
         break;
       case TimeStep.week:
       case TimeStep.last7Days:
         currentRange = DateTimeRange(
-          start: oldStart.copyWith(day: oldStart.day + directionalStep * 7),
-          end: oldEnd.copyWith(day: oldEnd.day + directionalStep * 7),
+          start: oldStart.add(Duration(days: directionalStep * 7)),
+          end: oldEnd.add(Duration(days: directionalStep * 7)),
         );
         break;
       case TimeStep.month:
         currentRange = DateTimeRange(
+          // No fitting Duration: wraps correctly according to doc
           start: oldStart.copyWith(month: oldStart.month + directionalStep),
           end: oldEnd.copyWith(month: oldEnd.month + directionalStep),
         );
         break;
       case TimeStep.year:
         currentRange = DateTimeRange(
+          // No fitting Duration: wraps correctly according to doc
           start: oldStart.copyWith(year: oldStart.year + directionalStep),
           end: oldEnd.copyWith(year: oldEnd.year + directionalStep),
         );
@@ -101,8 +103,8 @@ class IntervallStorage extends ChangeNotifier {
         break;
       case TimeStep.last30Days:
         currentRange = DateTimeRange(
-            start: oldStart.copyWith(day: oldStart.day + directionalStep * 30),
-            end: oldEnd.copyWith(day: oldEnd.day + directionalStep * 30),
+            start: oldStart.add(Duration(days: directionalStep * 30)),
+            end: oldEnd.add(Duration(days:  directionalStep * 30)),
         );
         break;
       case TimeStep.custom:
@@ -135,11 +137,11 @@ class IntervallStorage extends ChangeNotifier {
         final endOfToday = now.copyWith(hour: 23, minute: 59, second: 59);
         return DateTimeRange(start: start, end: endOfToday);
       case TimeStep.last7Days:
-        final start = now.copyWith(day: now.day - 7);
+        final start = now.subtract(const Duration(days: 7));
         final endOfToday = now.copyWith(hour: 23, minute: 59, second: 59);
         return DateTimeRange(start: start, end: endOfToday);
       case TimeStep.last30Days:
-        final start = now.copyWith(day: now.day - 30);
+        final start = now.subtract(const Duration(days: 30));
         final endOfToday = now.copyWith(hour: 23, minute: 59, second: 59);
         return DateTimeRange(start: start, end: endOfToday);
       case TimeStep.custom: