Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrectly labeled days of month #14

Open
approachableGeek opened this issue Jul 8, 2020 · 2 comments
Open

Incorrectly labeled days of month #14

approachableGeek opened this issue Jul 8, 2020 · 2 comments

Comments

@approachableGeek
Copy link

Describe the bug
November 2020 has two 1st's

To Reproduce
Steps to reproduce the behavior:

  1. Clone master
  2. Flutter pub get
  3. Flutter run (example)
  4. Select any calendar method
  5. Scroll to November 2020
  6. Sunday is correctly labeled as the 1st, Monday the 2nd is incorrectly labeled as the 1st as well shifting the entire month off my 1 day

Expected behavior
Days of the month should never repeat within the same month.

Screenshots
Simulator Screen Shot - iPhone 11 - 2020-07-08 at 08 43 49

Smartphone:

  • Device: iPhone11 Simulator
  • OS: iOS13.5

Additional context
Flutter Channel master, 1.20.0-2.0.pre

@approachableGeek
Copy link
Author

It appears that this line isn't doing what would be expected

dateTime = dateTime..add(days: startDayOffset);

The new dateTime after adding a startDayOffset of 1 for the 1st of November is still November 1st and 23 hours
A not so great solution could be to add something like

var tempTime = dateTime;
dateTime = dateTime..add(days: startDayOffset);
if (dateTime.dateTime.day == tempTime.dateTime.day) {
   dateTime = dateTime..add(hours: 1);
}

I hope that this helps in finding the cause of the issue and it can come to a good solution.

@approachableGeek
Copy link
Author

Looks like it is an issue with Jiffy from what I can tell anything between UTC-9:00 and UTC-2:00 is exhibiting this issue

import 'package:jiffy/jiffy.dart';
import 'package:timezone/timezone.dart' as tz;
import 'package:timezone/data/latest.dart' as tz;
import 'package:timezone/timezone.dart';

void main() {
  var incorrectOffsets = Set<int>();
  tz.initializeTimeZones();
  var locations = tz.timeZoneDatabase.locations;
  locations.values.forEach((location) {
    // MANIPULATING DATES
    var dateTime = Jiffy(TZDateTime(location, 2020, 11, 1));
    var nextDateTime = dateTime..add(days: 1);
    if (nextDateTime.day == 1) {
      incorrectOffsets.add(location.currentTimeZone.offset / 1000 / 60 ~/ 60);
    }
  });

  var inCorrectOffsetsList = incorrectOffsets.toList()..sort();
  inCorrectOffsetsList.forEach((offset) {
    print(offset);
  });
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant